Skip to content

Commit

Permalink
fix quit order (#933)
Browse files Browse the repository at this point in the history
Co-authored-by: SIGSEGV <[email protected]>
Co-authored-by: Ti Prow Robot <[email protected]>
  • Loading branch information
3 people authored Dec 1, 2020
1 parent 7d602d5 commit 214441a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions components/playground/instance/proc_attr_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ import "syscall"
// SysProcAttr to be use for every Process we start.
var SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
Setpgid: true,
}
9 changes: 5 additions & 4 deletions components/playground/playground.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ func (p *Playground) addWaitInstance(inst instance.Instance) {
}

func (p *Playground) handleScaleOut(w io.Writer, cmd *Command) error {
// Ignore Config.Num, alway one command as scale out one instance.
// Ignore Config.Num, always one command as scale out one instance.
err := p.sanitizeComponentConfig(cmd.ComponentID, &cmd.Config)
if err != nil {
return err
Expand Down Expand Up @@ -528,7 +528,7 @@ func (p *Playground) RWalkInstances(fn func(componentID string, ins instance.Ins
return nil
}

// WalkInstances call fn for every intance and stop if return not nil.
// WalkInstances call fn for every instance and stop if return not nil.
func (p *Playground) WalkInstances(fn func(componentID string, ins instance.Instance) error) error {
for _, ins := range p.pds {
err := fn("pd", ins)
Expand Down Expand Up @@ -647,7 +647,7 @@ func (p *Playground) addInstance(componentID string, cfg instance.Config) (ins i
ins = inst
p.drainers = append(p.drainers, inst)
default:
return nil, errors.Errorf("unknow component: %s", componentID)
return nil, errors.Errorf("unknown component: %s", componentID)
}

return
Expand Down Expand Up @@ -918,7 +918,8 @@ func (p *Playground) terminate(sig syscall.Signal) {
timer.Stop()
}

for _, inst := range p.startedInstances {
for i := len(p.startedInstances); i > 0; i-- {
inst := p.startedInstances[i-1]
if sig == syscall.SIGKILL {
fmt.Printf("Force %s(%d) to quit...\n", inst.Component(), inst.Pid())
} else if atomic.LoadInt32(&p.curSig) == int32(sig) { // In case of double ctr+c
Expand Down

0 comments on commit 214441a

Please sign in to comment.