Exemple #1
0
func TestMain_Simple(t *testing.T) {
	cfg := config.New()

	s, err := Main(cfg)
	if err != nil {
		t.Fatalf("Error during service startup: %v\n", err)
	}

	if s == nil {
		t.Fatal("The server instance was not initialized")
	}
}
Exemple #2
0
func main() {
	// Send everything to stdout to play nicely with heroku
	log.SetOutput(os.Stdout)

	conf := config.New()
	if err := conf.Load(os.Args[1:]); err != nil {
		config.Usage(os.Args[0])
		fmt.Printf("\nerror:\n%s\n", err.Error())
		os.Exit(2)
	}

	if conf.ShowHelp {
		config.Usage(os.Args[0])
		os.Exit(0)
	}

	if conf.ShowVersion {
		fmt.Println(VersionString)
		os.Exit(0)
	}

	if conf.ShowRevision {
		fmt.Println(RevisionString)
		os.Exit(0)
	}

	if conf.ShowVersionPlus {
		fmt.Println(VersionPlusJSON)
		os.Exit(0)
	}

	defer func() {
		err := recover()
		if err != nil {
			log.Fatal(err)
		}
	}()

	log.Println("hustle starting up server(s)")

	srv, err := server.Main(conf)
	if err != nil {
		log.Println("an unrecoverable error was encountered")
		log.Printf("error: %+v\n", err)
	}

	srv.Start()
}