示例#1
0
func main() {
	// ---------------------------
	// Setting Active Environment
	// ---------------------------

	if len(os.Args) > 1 {
		err := environment.Set(os.Args[1])
		if err != nil {
			log.Fatal(err)
		}
	} else {
		log.Fatal("Running requires an environment argument")
	}

	// ---------
	// Database
	// ---------

	db.Open()
	defer db.Close()

	// -----
	// Echo
	// -----

	e := request.BuildEcho()

	// ----
	// Run
	// ----

	port := environment.GetEnvVar(environment.PORT)
	log.Println("Server started on :" + port)
	graceful.ListenAndServe(e.Server(":"+port), 5*time.Second) // Graceful shutdown
}
示例#2
0
func (suite *ApiTestSuite) SetupTest() {
	// Loading .env file.  We're not failing here in the
	// event that the .env file can't be loaded. The
	// project might be running through a CI system
	// and the environment variables.  Will fail later
	// rather than early
	environment.SetWithRelativeDirectory("../", environment.TESTING)

	// Starting database
	db.Open()

	// Getting our Echo instance
	e := BuildEcho()

	// Running the server
	port := environment.GetEnvVar(environment.PORT)
	suite.wreckerClient = wrecker.New("http://localhost:" + port)
	log.Println("Server started on :" + port)
	go graceful.ListenAndServe(e.Server(":"+port), 5*time.Second) // Graceful shutdown
}