mirror of
https://github.com/wahyd4/forego.git
synced 2026-08-09 05:07:05 +10:00
Refactor ShutdownProcess to smaller platform-specific part
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}()
|
||||
}
|
||||
|
||||
+3
-6
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user