示例#1
0
文件: main.go 项目: shawnps/wikifeat
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))
	}
}
示例#2
0
文件: main.go 项目: shawnps/wikifeat
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()
}
示例#3
0
文件: main.go 项目: rhinoman/wikifeat
func parseCmdParams() string {
	defaultConfig, err := util.DefaultConfigLocation()
	if err != nil {
		log.Fatalf("Error setting config file: %v", err)
	}
	hostName := flag.String("hostName", "localhost", "The host name for this instance")
	nodeId := flag.String("nodeId", "cfg1", "The node Id for this instance")
	port := flag.String("port", "4140", "The port number for this instance")
	useSSL := flag.Bool("useSSL", false, "use SSL")
	sslCertFile := flag.String("sslCertFile", "", "The SSL certificate file")
	sslKeyFile := flag.String("sslKeyFile", "", "The SSL key file")
	registryLocation := flag.String("registryLocation", "http://localhost:2379", "URL for etcd")
	configFile := flag.String("config", defaultConfig, "config file to load")
	flag.Parse()
	config.Service.DomainName = *hostName
	config.Service.NodeId = *nodeId
	config.Service.Port = *port
	config.Service.UseSSL = *useSSL
	config.Service.SSLCertFile = *sslCertFile
	config.Service.SSLKeyFile = *sslKeyFile
	config.Service.RegistryLocation = *registryLocation
	return *configFile
}