|
@@ -9,7 +9,16 @@ import (
|
|
|
)
|
|
|
|
|
|
func execShell(cmd string) (out string) {
|
|
|
- bytes, err := exec.Command("/bin/sh -c", cmd).CombinedOutput()
|
|
|
+ bytes, err := exec.Command("/bin/sh", "-c", cmd).CombinedOutput()
|
|
|
+ out = string(bytes)
|
|
|
+ if err != nil {
|
|
|
+ out += " " + err.Error()
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func execCommand(name string, cmd ...string) (out string) {
|
|
|
+ bytes, err := exec.Command(name, cmd...).CombinedOutput()
|
|
|
out = string(bytes)
|
|
|
if err != nil {
|
|
|
out += " " + err.Error()
|
|
@@ -24,7 +33,7 @@ func TestConf() (out string) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- out = execShell("nginx -t")
|
|
|
+ out = execCommand("nginx", "-t")
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -35,7 +44,7 @@ func Reload() (out string) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- out = execShell("nginx -s reload")
|
|
|
+ out = execCommand("nginx", "-s", "reload")
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -47,7 +56,9 @@ func Restart() (out string) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- out = execShell("nginx -s reopen")
|
|
|
+ out = execCommand("nginx", "-s", "stop")
|
|
|
+
|
|
|
+ out += execCommand("nginx")
|
|
|
|
|
|
return
|
|
|
}
|