fix(task/cron): use the correct pointer to build structure
feat(init): included enviroment variable and working directory test(cron): wip
This commit is contained in:
10
init/cron.go
10
init/cron.go
@@ -2,6 +2,7 @@ package init
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -34,6 +35,15 @@ 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()...)
|
||||
}
|
||||
|
||||
if len(cron.WorkingDir()) > 0 {
|
||||
cmd.Dir = cron.WorkingDir()
|
||||
}
|
||||
|
||||
iwg = &sync.WaitGroup{}
|
||||
|
||||
if stdout, err = cmd.StdoutPipe(); err != nil {
|
||||
|
||||
@@ -25,6 +25,7 @@ type Task interface {
|
||||
Name() string
|
||||
Command() string
|
||||
Arguments() []string
|
||||
EnvLen() int
|
||||
Environ() []string
|
||||
Setsid() bool
|
||||
UserGroup() UserGroup
|
||||
|
||||
@@ -3,6 +3,7 @@ package init
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -39,6 +40,15 @@ 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()...)
|
||||
}
|
||||
|
||||
if len(task.WorkingDir()) > 0 {
|
||||
cmd.Dir = task.WorkingDir()
|
||||
}
|
||||
|
||||
iwg = &sync.WaitGroup{}
|
||||
|
||||
if stdout, err = cmd.StdoutPipe(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user