Skip to content

Commit

Permalink
Merge pull request #134 from ifooth/dev-joelei-gracefully
Browse files Browse the repository at this point in the history
Update: interrupt can close the log normally
  • Loading branch information
tbs60 authored Oct 26, 2023
2 parents 9766210 + 637ea62 commit 722a7d1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/backend/booster/bk_dist/executor/pkg/dist_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion src/backend/booster/bk_dist/idleloop/command/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/backend/booster/bk_dist/idleloop/pkg/idleloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions src/backend/booster/bk_dist/monitor/command/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/backend/booster/bk_dist/shadertool/command/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/backend/booster/bk_dist/ubttool/command/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 722a7d1

Please sign in to comment.