Beispiel #1
0
func main() {
	defaultConfig, err := util.DefaultConfigLocation()
	if err != nil {
		log.Fatalf("Error setting config file: %v", err)
	}
	// Get command line arguments
	configFile := flag.String("config", defaultConfig, "config file to load")
	flag.Parse()
	// Load configuration
	config.LoadConfig(*configFile)
	// Set up logger
	log.SetOutput(&lumberjack.Logger{
		Filename:   config.Logger.LogFile,
		MaxSize:    config.Logger.MaxSize,
		MaxBackups: config.Logger.MaxBackups,
		MaxAge:     config.Logger.MaxAge,
	})
	wsContainer := restful.NewContainer()
	wsContainer.Router(restful.CurlyRouter{})
	//Enable Gzip support
	wsContainer.EnableContentEncoding(true)
	uc := user_service.UsersController{}
	uc.Register(wsContainer)
	services.InitDb()
	registry.Init("Users", registry.UsersLocation)
	httpAddr := ":" + config.Service.Port
	if config.Service.UseSSL == true {
		certFile := config.Service.SSLCertFile
		keyFile := config.Service.SSLKeyFile
		log.Fatal(http.ListenAndServeTLS(httpAddr,
			certFile, keyFile, wsContainer))
	} else {
		log.Fatal(http.ListenAndServe(httpAddr, wsContainer))
	}
}
Beispiel #2
0
func main() {
	defaultConfig, err := util.DefaultConfigLocation()
	if err != nil {
		log.Fatalf("Error settting config file: %v", err)
	}
	// Get Command line arguments
	configFile := flag.String("config", defaultConfig, "config file to load")
	flag.Parse()
	// Load configuration
	config.LoadConfig(*configFile)
	fserv.LoadPluginData(config.Frontend.PluginDir + "/plugins.ini")
	services.InitDb()
	// Set up the core logger
	log.SetOutput(&lumberjack.Logger{
		Filename:   config.Logger.LogFile,
		MaxSize:    config.Logger.MaxSize,
		MaxBackups: config.Logger.MaxBackups,
		MaxAge:     config.Logger.MaxAge,
	})
	registry.Init("Frontend", registry.FrontEndLocation)
	routing.Start()
}
Beispiel #3
0
func main() {
	// Get command line arguments
	configFile := parseCmdParams()
	// Load Configuration
	config.LoadConfig(configFile)
	// Set up Logger
	log.SetOutput(&lumberjack.Logger{
		Filename:   config.Logger.LogFile,
		MaxSize:    config.Logger.MaxSize,
		MaxBackups: config.Logger.MaxBackups,
		MaxAge:     config.Logger.MaxAge,
	})
	// Initialize our etcd and couchdb connections
	config_loader.InitRegistry()
	config_loader.InitDatabase()
	// Clear out any old config that may be hanging around
	config_loader.ClearConfig()
	// Set the configuration keys in etcd
	config_loader.SetConfig()
	//Start up the config service
	wsContainer := restful.NewContainer()
	wsContainer.Router(restful.CurlyRouter{})
	//Enable GZIP support
	wsContainer.EnableContentEncoding(true)
	cc := config_service.ConfigController{}
	cc.Register(wsContainer)
	registry.Init("Config", registry.ConfigServiceLocation)
	httpAddr := ":" + config.Service.Port
	if config.Service.UseSSL == true {
		certFile := config.Service.SSLCertFile
		keyFile := config.Service.SSLKeyFile
		log.Fatal(http.ListenAndServeTLS(httpAddr,
			certFile, keyFile, wsContainer))
	} else {
		log.Fatal(http.ListenAndServe(httpAddr, wsContainer))
	}
}