Skip to content

Commit b055c54

Browse files
committed
fix(nginx): improve execCommand to set working directory for Nginx execution #1046
1 parent 5c60363 commit b055c54

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

internal/nginx/config_args.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func getNginxExeDir() string {
4141

4242
func getNginxV() string {
4343
exePath := getNginxExePath()
44-
out, err := exec.Command(exePath, "-V").CombinedOutput()
44+
out, err := execCommand(exePath, "-V")
4545
if err != nil {
4646
logger.Error(err)
4747
return ""

internal/nginx/exec.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ func execCommand(name string, cmd ...string) (stdOut string, stdErr error) {
1818
cmd = append([]string{name}, cmd...)
1919
stdOut, stdErr = docker.Exec(context.Background(), cmd)
2020
case false:
21-
bytes, err := exec.Command(name, cmd...).CombinedOutput()
21+
execCmd := exec.Command(name, cmd...)
22+
// fix #1046
23+
execCmd.Dir = getNginxExeDir()
24+
bytes, err := execCmd.CombinedOutput()
2225
stdOut = string(bytes)
2326
if err != nil {
2427
stdErr = err

0 commit comments

Comments
 (0)