當前位置: 首頁>>代碼示例>>Golang>>正文


Golang GracefulServer.ListenAndServe方法代碼示例

本文整理匯總了Golang中github.com/mailgun/manners.GracefulServer.ListenAndServe方法的典型用法代碼示例。如果您正苦於以下問題:Golang GracefulServer.ListenAndServe方法的具體用法?Golang GracefulServer.ListenAndServe怎麽用?Golang GracefulServer.ListenAndServe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/mailgun/manners.GracefulServer的用法示例。


在下文中一共展示了GracefulServer.ListenAndServe方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: serve

func (s *srv) serve(srv *manners.GracefulServer) {
	log.Infof("%s serve", s)

	s.mux.wg.Add(1)
	defer s.mux.wg.Done()

	srv.ListenAndServe()

	log.Infof("%v stop", s)
}
開發者ID:vulcand,項目名稱:vulcand,代碼行數:10,代碼來源:srv.go

示例2: startServer

func (server *Server) startServer(srv *manners.GracefulServer, globalConfiguration GlobalConfiguration) {
	log.Infof("Starting server on %s", srv.Addr)
	if srv.TLSConfig != nil {
		if err := srv.ListenAndServeTLSWithConfig(srv.TLSConfig); err != nil {
			log.Fatal("Error creating server: ", err)
		}
	} else {
		if err := srv.ListenAndServe(); err != nil {
			log.Fatal("Error creating server: ", err)
		}
	}
	log.Info("Server stopped")
}
開發者ID:vdemeester,項目名稱:traefik,代碼行數:13,代碼來源:server.go

示例3: startServer

func startServer(srv *manners.GracefulServer, globalConfiguration *GlobalConfiguration) {
	log.Info("Starting server")
	if srv.TLSConfig != nil {
		err := srv.ListenAndServeTLSWithConfig(srv.TLSConfig)
		if err != nil {
			log.Fatal("Error creating server: ", err)
		}
	} else {
		err := srv.ListenAndServe()
		if err != nil {
			log.Fatal("Error creating server: ", err)
		}
	}
	log.Info("Server stopped")
}
開發者ID:abhishekamralkar,項目名稱:traefik,代碼行數:15,代碼來源:traefik.go

示例4: startServer

func startServer(srv *manners.GracefulServer, globalConfiguration *GlobalConfiguration) {
	log.Info("Starting server")
	if len(globalConfiguration.CertFile) > 0 && len(globalConfiguration.KeyFile) > 0 {
		err := srv.ListenAndServeTLS(globalConfiguration.CertFile, globalConfiguration.KeyFile)
		if err != nil {
			log.Fatal("Error creating server: ", err)
		}
	} else {
		err := srv.ListenAndServe()
		if err != nil {
			log.Fatal("Error creating server: ", err)
		}
	}
	log.Info("Server stopped")
}
開發者ID:rasata,項目名稱:traefik,代碼行數:15,代碼來源:traefik.go

示例5: startServer

func startServer(srv *manners.GracefulServer, globalConfiguration *GlobalConfiguration) {
	log.Info("Starting server")
	if len(globalConfiguration.CertFile) > 0 && len(globalConfiguration.KeyFile) > 0 {
		err := srv.ListenAndServeTLS(globalConfiguration.CertFile, globalConfiguration.KeyFile)
		if err != nil {
			netOpError, ok := err.(*net.OpError)
			if ok && netOpError.Err.Error() != "use of closed network connection" {
				log.Fatal("Error creating server: ", err)
			}
		}
	} else {
		err := srv.ListenAndServe()
		if err != nil {
			netOpError, ok := err.(*net.OpError)
			if ok && netOpError.Err.Error() != "use of closed network connection" {
				log.Fatal("Error creating server: ", err)
			}
		}
	}
	log.Info("Server stopped")
}
開發者ID:zackslash,項目名稱:traefik,代碼行數:21,代碼來源:traefik.go


注:本文中的github.com/mailgun/manners.GracefulServer.ListenAndServe方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。