feat(config): enable or disable httpd server. (#262)
This commit is contained in:
@@ -255,3 +255,12 @@ func TestMetricsHandler(t *testing.T) {
|
||||
assert.Equal(t, http.StatusOK, r.Code)
|
||||
})
|
||||
}
|
||||
|
||||
func TestDisabledHTTPServer(t *testing.T) {
|
||||
initTest()
|
||||
PushConf.Core.Enabled = false
|
||||
err := RunHTTPServer()
|
||||
PushConf.Core.Enabled = true
|
||||
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ import (
|
||||
|
||||
// RunHTTPServer provide run http or https protocol.
|
||||
func RunHTTPServer() (err error) {
|
||||
if !PushConf.Core.Enabled {
|
||||
LogAccess.Debug("httpd server is disabled.")
|
||||
return nil
|
||||
}
|
||||
|
||||
LogAccess.Debug("HTTPD server is running on " + PushConf.Core.Port + " port.")
|
||||
if PushConf.Core.AutoTLS.Enabled {
|
||||
err = gracehttp.Serve(autoTLSServer())
|
||||
|
||||
@@ -8,6 +8,11 @@ import (
|
||||
|
||||
// RunHTTPServer provide run http or https protocol.
|
||||
func RunHTTPServer() (err error) {
|
||||
if !PushConf.Core.Enabled {
|
||||
LogAccess.Debug("httpd server is disabled.")
|
||||
return nil
|
||||
}
|
||||
|
||||
if PushConf.Core.AutoTLS.Enabled {
|
||||
s := autoTLSServer()
|
||||
err = s.ListenAndServeTLS("", "")
|
||||
|
||||
Reference in New Issue
Block a user