fix metadata port, appsrv add check quitHandlerRegisted

This commit is contained in:
wanyaoqi
2019-02-28 21:15:45 +08:00
parent c7b29175da
commit 314d99d2b4
2 changed files with 10 additions and 4 deletions
+9 -3
View File
@@ -53,6 +53,8 @@ const (
DEFAULT_PROCESS_TIMEOUT = 15 * time.Second
)
var quitHandlerRegisted bool
func NewApplication(name string, connMax int, db bool) *Application {
app := Application{name: name,
context: context.Background(),
@@ -333,6 +335,12 @@ func (app *Application) initServer(addr string) *http.Server {
}
func (app *Application) registerCleanShutdown(s *http.Server, onStop func()) {
if quitHandlerRegisted {
log.Warningf("Application quit handler registed, duplicated!!!")
return
} else {
quitHandlerRegisted = true
}
app.idleConnsClosed = make(chan struct{})
// dump goroutine stack
@@ -388,9 +396,7 @@ func (app *Application) ListenAndServeWithCleanup(addr string, onStop func()) {
func (app *Application) ListenAndServeTLSWithCleanup(addr string, certFile, keyFile string, onStop func()) {
s := app.initServer(addr)
if onStop != nil {
app.registerCleanShutdown(s, onStop)
}
app.registerCleanShutdown(s, onStop)
var err error
if len(certFile) == 0 && len(keyFile) == 0 {
@@ -447,7 +447,7 @@ func (o *SOVSBridgeDriver) GetOfRules(nic jsonutils.JSONObject) []SRule {
}
func (o *SOVSBridgeDriver) GetMetadataServerPort() int {
return options.HostOptions.Port
return options.HostOptions.Port + 1000
}
func (o *SOVSBridgeDriver) RegisterHostlocalServer(mac, ip string) error {