Skip to content

Commit 2c92b43

Browse files
committed
optimized(host): SetDumpStackSignal handler at startup
1 parent 712c6d0 commit 2c92b43

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

pkg/appsrv/appsrv.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,16 +574,20 @@ func (app *Application) ListenAndServeWithoutCleanup(addr, certFile, keyFile str
574574
func (app *Application) ListenAndServeTLSWithCleanup2(addr string, certFile, keyFile string, onStop func(), isMaster bool) {
575575
app.isTLS = true
576576
httpSrv := app.initServer(addr)
577+
log.Infof("listen on %s, isMaster: %v, certFile: %s, keyFile: %s", addr, isMaster, certFile, keyFile)
577578
if isMaster {
578579
app.addDefaultHandlers()
579580
if app.enableProfiling {
580581
addPProfHandler("", app)
581582
}
582583
app.httpServer = httpSrv
584+
log.Infof("----------register cleanShutdown")
583585
app.registerCleanShutdown(app.httpServer, onStop)
586+
log.Infof("----------end register cleanShutdown")
584587
} else {
585588
app.slaveHttpServer = httpSrv
586589
}
590+
log.Infof("[listenAndServeInternal] listen on %s, isMaster: %v, certFile: %s, keyFile: %s", addr, isMaster, certFile, keyFile)
587591
app.listenAndServeInternal(httpSrv, certFile, keyFile)
588592
if isMaster {
589593
app.waitCleanShutdown()

pkg/hostman/host_services.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package hostman
1717
import (
1818
execlient "yunion.io/x/executor/client"
1919
"yunion.io/x/log"
20+
"yunion.io/x/pkg/util/signalutils"
2021

2122
"yunion.io/x/onecloud/pkg/appsrv"
2223
app_common "yunion.io/x/onecloud/pkg/cloudcommon/app"
@@ -157,6 +158,10 @@ func (host *SHostService) initHandlers(app *appsrv.Application) {
157158
}
158159

159160
func StartService() {
161+
// register dump stack signal handler at first
162+
signalutils.SetDumpStackSignal()
163+
signalutils.StartTrap()
164+
160165
var srv = &SHostService{}
161166
srv.SServiceBase = &service.SServiceBase{
162167
Service: srv,

vendor/yunion.io/x/pkg/util/signalutils/signalutils.go

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/yunion.io/x/pkg/utils/profiler.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)