Exemple #1
0
func RunServer() {
	app := cli.NewApp()
	app.Name = "omnistore-server"
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "config-file",
			Value: "conf/development.toml",
			Usage: "configuration file",
		},
	}
	app.Action = func(c *cli.Context) {
		configFile := c.String("config-file")
		LOG.Info("loading configuration %s ...\n", configFile)
		CONF.MustLoadFile(configFile)
		LOG.Info("starting server\n")
		m := martini.Classic()
		m.Map(m)
		m.Use(db.GetMartiniMiddleware())
		m.Get("/", func() string { return "It works!" })
		m.Run()
		// serverListen := CONF.GetString("server.listen", "127.0.0.1:3000")
		// LOG.Info("listening on %s\n", serverListen)
		// LOG.Fatal(http.ListenAndServe(serverListen, m))
	}
	app.Run(os.Args)
}
Exemple #2
0
func (s *DBSuite) SetUpSuite(c *C) {
	// Use s.dir to prepare some data.
	var err error

	configFile := utils.GetLocalFilePath("conf/testing.toml")
	LOG.Info("loading configuration %s ...\n", configFile)
	CONF.MustLoadFile(configFile)

	dialect := CONF.GetString("database.dialect", "")
	connection := CONF.GetString("database.connection", "")
	// clean testing database
	s.dbapi, err = NewDBAPI(dialect, connection)
	if err != nil {
		c.Error(err)
	}
	s.dbapi.db.MustExec("DROP SCHEMA IF EXISTS public CASCADE")
}