From 637ea629faad0a8a191363a93d1d3e68113fcd4e Mon Sep 17 00:00:00 2001 From: ifooth Date: Thu, 26 Oct 2023 16:23:12 +0800 Subject: [PATCH] Update: interrupt can close the log normally --- src/backend/booster/bk_dist/executor/pkg/dist_executor.go | 1 + src/backend/booster/bk_dist/idleloop/command/process.go | 4 +++- src/backend/booster/bk_dist/idleloop/pkg/idleloop.go | 4 ++-- src/backend/booster/bk_dist/monitor/command/process.go | 2 ++ src/backend/booster/bk_dist/shadertool/command/process.go | 2 ++ src/backend/booster/bk_dist/ubttool/command/process.go | 4 +++- 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/backend/booster/bk_dist/executor/pkg/dist_executor.go b/src/backend/booster/bk_dist/executor/pkg/dist_executor.go index 2266e0e2..bf65b8cf 100644 --- a/src/backend/booster/bk_dist/executor/pkg/dist_executor.go +++ b/src/backend/booster/bk_dist/executor/pkg/dist_executor.go @@ -265,6 +265,7 @@ func (d *DistExecutor) sysSignalHandler() { select { case sig := <-interrupt: blog.Warnf("executor-command: get system signal %s, going to exit", sig.String()) + blog.CloseLogs() // catch control-C and should return code 130(128+0x2) if sig == syscall.SIGINT { diff --git a/src/backend/booster/bk_dist/idleloop/command/process.go b/src/backend/booster/bk_dist/idleloop/command/process.go index 6c7db944..dc708655 100644 --- a/src/backend/booster/bk_dist/idleloop/command/process.go +++ b/src/backend/booster/bk_dist/idleloop/command/process.go @@ -55,11 +55,13 @@ func sysSignalHandler(cancel context.CancelFunc, _ *pkg.IdleLoop) { p, err := process.NewProcess(int32(os.Getpid())) if err == nil { - blog.Debugf("idelloop: ready kill children when recieved sinal") + blog.Debugf("idelloop: ready kill children when received signal") // kill children pkg.KillChildren(p) } + blog.CloseLogs() + // catch control-C and should return code 130(128+0x2) if sig == syscall.SIGINT { os.Exit(130) diff --git a/src/backend/booster/bk_dist/idleloop/pkg/idleloop.go b/src/backend/booster/bk_dist/idleloop/pkg/idleloop.go index 1e73d761..8fbc880a 100644 --- a/src/backend/booster/bk_dist/idleloop/pkg/idleloop.go +++ b/src/backend/booster/bk_dist/idleloop/pkg/idleloop.go @@ -88,7 +88,7 @@ func (l *IdleLoop) runCommitSuicideCheck(ctx context.Context) { // // kill self // _ = p.Kill() // } - blog.Infof("booster: commit suicide for parent process %d not existed", l.ppid) + blog.Infof("idelloop: commit suicide for parent process %d not existed", l.ppid) blog.CloseLogs() os.Exit(0) } @@ -102,7 +102,7 @@ func (l *IdleLoop) runCommitSuicideCheck(ctx context.Context) { // // kill self // _ = p.Kill() // } - blog.Infof("booster: commit suicide for grandfather process %d not existed", l.pppid) + blog.Infof("idelloop: commit suicide for grandfather process %d not existed", l.pppid) blog.CloseLogs() os.Exit(0) } diff --git a/src/backend/booster/bk_dist/monitor/command/process.go b/src/backend/booster/bk_dist/monitor/command/process.go index 70cb8868..c767a0cb 100644 --- a/src/backend/booster/bk_dist/monitor/command/process.go +++ b/src/backend/booster/bk_dist/monitor/command/process.go @@ -60,6 +60,8 @@ func sysSignalHandler(cancel context.CancelFunc, _ *pkg.Monitor) { // cancel context cancel() + blog.CloseLogs() + // catch control-C and should return code 130(128+0x2) if sig == syscall.SIGINT { os.Exit(130) diff --git a/src/backend/booster/bk_dist/shadertool/command/process.go b/src/backend/booster/bk_dist/shadertool/command/process.go index 88fd9e34..787547d3 100644 --- a/src/backend/booster/bk_dist/shadertool/command/process.go +++ b/src/backend/booster/bk_dist/shadertool/command/process.go @@ -60,6 +60,8 @@ func sysSignalHandler(cancel context.CancelFunc, handle *pkg.ShaderTool) { // handle.Clean() handle.ReleaseResource() + blog.CloseLogs() + // catch control-C and should return code 130(128+0x2) if sig == syscall.SIGINT { os.Exit(130) diff --git a/src/backend/booster/bk_dist/ubttool/command/process.go b/src/backend/booster/bk_dist/ubttool/command/process.go index 84f2cabf..04a0a42d 100644 --- a/src/backend/booster/bk_dist/ubttool/command/process.go +++ b/src/backend/booster/bk_dist/ubttool/command/process.go @@ -53,11 +53,13 @@ func sysSignalHandler(cancel context.CancelFunc, handle *pkg.UBTTool) { select { case sig := <-interrupt: - blog.Warnf("helptool: get system signal %s, going to exit", sig.String()) + blog.Warnf("ubttool: get system signal %s, going to exit", sig.String()) // cancel handle's context and make sure that task is released. cancel() + blog.CloseLogs() + // catch control-C and should return code 130(128+0x2) if sig == syscall.SIGINT { os.Exit(130)