コード例 #1
0
ファイル: main.go プロジェクト: firebitsbr/wikifeat
func main() {
	// Get command line arguments
	configFile := flag.String("config", "config.ini", "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
	wsContainer.EnableContentEncoding(true)
	//Register the notifications controller
	nc := notification_service.NotificationsController{}
	nc.Register(wsContainer)
	services.InitDb()
	//Register with the service registry
	registry.Init("Notifications", registry.NotificationsLocation)
	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))
	}
}
コード例 #2
0
ファイル: main.go プロジェクト: rhinoman/wikifeat
func main() {
	// Load the default config
	config.LoadDefaults()
	//Parse the command line parameters
	config.ParseCmdParams(config.DefaultCmdLine{
		HostName:         "localhost",
		NodeId:           "ns1",
		Port:             "4120",
		UseSSL:           false,
		RegistryLocation: "http://localhost:2379",
	})
	// Fetch Configuration from etcd
	config.InitEtcd()
	config.FetchCommonConfig()
	config.FetchServiceSection(config.NotificationService)
	// 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
	wsContainer.EnableContentEncoding(true)
	//Register the notifications controller
	nc := notification_service.NotificationsController{}
	nc.Register(wsContainer)
	database.InitDb()
	//Register with the service registry
	registry.Init("Notifications", registry.NotificationsLocation)
	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))
	}
}