Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the exit order of the components of playground #933

Merged
merged 6 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -919,7 +919,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