コード例 #1
0
ファイル: web.go プロジェクト: roman-vynar/grafana
func StartServer() int {
	logger = log.New("server")

	var err error
	m := newMacaron()
	api.Register(m)

	listenAddr := fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort)
	logger.Info("Server Listening", "address", listenAddr, "protocol", setting.Protocol, "subUrl", setting.AppSubUrl)
	switch setting.Protocol {
	case setting.HTTP:
		err = http.ListenAndServe(listenAddr, m)
	case setting.HTTPS:
		err = http.ListenAndServeTLS(listenAddr, setting.CertFile, setting.KeyFile, m)
	default:
		logger.Error("Invalid protocol", "protocol", setting.Protocol)
		return 1
	}

	if err != nil {
		logger.Error("Fail to start server", "error", err)
		return 1
	}

	return 0
}
コード例 #2
0
ファイル: server.go プロジェクト: wk66/grafana
func (g *GrafanaServerImpl) startHttpServer() {
	logger = log.New("http.server")

	var err error
	m := newMacaron()
	api.Register(m)

	listenAddr := fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort)
	g.log.Info("Initializing HTTP Server", "address", listenAddr, "protocol", setting.Protocol, "subUrl", setting.AppSubUrl)

	switch setting.Protocol {
	case setting.HTTP:
		err = http.ListenAndServe(listenAddr, m)
	case setting.HTTPS:
		err = ListenAndServeTLS(listenAddr, setting.CertFile, setting.KeyFile, m)
	default:
		g.log.Error("Invalid protocol", "protocol", setting.Protocol)
		g.Shutdown(1, "Startup failed")
	}

	if err != nil {
		g.log.Error("Fail to start server", "error", err)
		g.Shutdown(1, "Startup failed")
		return
	}
}
コード例 #3
0
ファイル: web.go プロジェクト: toni-moreno/grafana
func StartServer() {

	var err error
	m := newMacaron()
	api.Register(m)

	listenAddr := fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort)
	log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubUrl)
	switch setting.Protocol {
	case setting.HTTP:
		err = http.ListenAndServe(listenAddr, m)
	case setting.HTTPS:
		err = http.ListenAndServeTLS(listenAddr, setting.CertFile, setting.KeyFile, m)
	default:
		log.Fatal(4, "Invalid protocol: %s", setting.Protocol)
	}

	if err != nil {
		log.Fatal(4, "Fail to start server: %v", err)
	}
}