* move "httpServer" to "config"

This commit is contained in:
Simon Zolin 2019-07-09 18:52:06 +03:00
parent 2780ace63e
commit 5e309a7b3a
3 changed files with 5 additions and 6 deletions

View File

@ -70,6 +70,7 @@ type configuration struct {
versionCheckJSON []byte
versionCheckLastTime time.Time
httpServer *http.Server
httpsServer HTTPSServer
BindHost string `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to

View File

@ -264,7 +264,7 @@ func handleInstallConfigure(w http.ResponseWriter, r *http.Request) {
// until all requests are finished, and _we_ are inside a request right now, so it will block indefinitely
if restartHTTP {
go func() {
httpServer.Shutdown(context.TODO())
config.httpServer.Shutdown(context.TODO())
}()
}

View File

@ -25,8 +25,6 @@ import (
"github.com/gobuffalo/packr"
)
var httpServer *http.Server
const (
// Used in config to indicate that syslog or eventlog (win) should be used for logger output
configSyslog = "syslog"
@ -197,10 +195,10 @@ func run(args options) {
// we need to have new instance, because after Shutdown() the Server is not usable
address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort))
httpServer = &http.Server{
config.httpServer = &http.Server{
Addr: address,
}
err := httpServer.ListenAndServe()
err := config.httpServer.ListenAndServe()
if err != http.ErrServerClosed {
cleanupAlways()
log.Fatal(err)
@ -397,7 +395,7 @@ func stopHTTPServer() {
if config.httpsServer.server != nil {
config.httpsServer.server.Shutdown(context.TODO())
}
httpServer.Shutdown(context.TODO())
config.httpServer.Shutdown(context.TODO())
}
// This function is called before application exits