diff --git a/start.go b/start.go index 28bed0c..992726f 100644 --- a/start.go +++ b/start.go @@ -179,3 +179,9 @@ func runStart(cmd *Command, args []string) { f.wg.Wait() } + +func ShutdownProcesses(of *OutletFactory) { + for name, p := range processes { + ShutdownProcess(of, p, name) + } +} diff --git a/unix.go b/unix.go index 73ef090..e49d609 100644 --- a/unix.go +++ b/unix.go @@ -33,16 +33,12 @@ func (p *Process) Signal(signal syscall.Signal) { } } -func ShutdownProcesses(of *OutletFactory) { - for name, ps := range processes { - of.SystemOutput(fmt.Sprintf("sending SIGTERM to %s", name)) - ps.Signal(syscall.SIGTERM) - } +func ShutdownProcess(of *OutletFactory, ps *Process, name string) { + of.SystemOutput(fmt.Sprintf("sending SIGTERM to %s", name)) + ps.Signal(syscall.SIGTERM) go func() { time.Sleep(shutdownGraceTime) - for name, ps := range processes { - of.SystemOutput(fmt.Sprintf("sending SIGKILL to %s", name)) - ps.Signal(syscall.SIGKILL) - } + of.SystemOutput(fmt.Sprintf("sending SIGKILL to %s", name)) + ps.Signal(syscall.SIGKILL) }() } diff --git a/windows.go b/windows.go index 862f95f..373647c 100644 --- a/windows.go +++ b/windows.go @@ -25,10 +25,7 @@ func (p *Process) Signal(signal syscall.Signal) { group.Signal(signal) } -func ShutdownProcesses(of *OutletFactory) { - for name, ps := range processes { - of.SystemOutput(fmt.Sprintf("terminating %s", name)) - ps.cmd.Process.Signal(os.Kill) - } - os.Exit(1) +func ShutdownProcess(of *OutletFactory, ps *Process, name string) { + of.SystemOutput(fmt.Sprintf("terminating %s", name)) + ps.cmd.Process.Signal(os.Kill) }