WIP: unit test done, need further test
This commit is contained in:
@@ -35,10 +35,7 @@ cron:
|
||||
goto fail
|
||||
}
|
||||
cmd = exec.Command(cron.Command(), cron.Arguments()...)
|
||||
cmd.Env = os.Environ()
|
||||
if cron.EnvLen() > 0 {
|
||||
cmd.Env = append(cmd.Env, cron.Environ()...)
|
||||
}
|
||||
cmd.Env = cron.PatchEnv(os.Environ())
|
||||
|
||||
if len(cron.WorkingDir()) > 0 {
|
||||
cmd.Dir = cron.WorkingDir()
|
||||
|
||||
@@ -27,6 +27,7 @@ type Task interface {
|
||||
Arguments() []string
|
||||
EnvLen() int
|
||||
Environ() []string
|
||||
PatchEnv([]string) []string
|
||||
Setsid() bool
|
||||
UserGroup() UserGroup
|
||||
WorkingDir() string
|
||||
|
||||
@@ -40,10 +40,7 @@ service:
|
||||
goto fail
|
||||
}
|
||||
cmd = exec.Command(task.Command(), task.Arguments()...)
|
||||
cmd.Env = os.Environ()
|
||||
if task.EnvLen() > 0 {
|
||||
cmd.Env = append(cmd.Env, task.Environ()...)
|
||||
}
|
||||
cmd.Env = task.PatchEnv(os.Environ())
|
||||
|
||||
if len(task.WorkingDir()) > 0 {
|
||||
cmd.Dir = task.WorkingDir()
|
||||
|
||||
@@ -19,14 +19,14 @@ func (i *Init) sighandler(wg *sync.WaitGroup, trigger chan<- any, selfExit <-cha
|
||||
isOpen := true
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, unix.SIGINT, unix.SIGTERM, unix.SIGCHLD)
|
||||
signal.Notify(c, unix.SIGINT, unix.SIGTERM, unix.SIGQUIT, unix.SIGCHLD)
|
||||
|
||||
signal:
|
||||
for {
|
||||
select {
|
||||
case s := <-c:
|
||||
switch s {
|
||||
case unix.SIGTERM, unix.SIGINT:
|
||||
case unix.SIGTERM, unix.SIGINT, unix.SIGQUIT:
|
||||
if isOpen {
|
||||
wingmate.Log().Info().Msg("initiating shutdown...")
|
||||
close(trigger)
|
||||
|
||||
Reference in New Issue
Block a user