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:
2024-03-29 11:30:36 +00:00
parent f2bfd6e60b
commit 3bdca8c540
8 changed files with 85 additions and 21 deletions
+10
View File
@@ -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 {