🛠️ fix:nginx reload命令报错
This commit is contained in:
@@ -2483,11 +2483,11 @@ func deployCertFiles(certPEM, keyPEM, certPath, keyPath, reloadTarget string) er
|
|||||||
|
|
||||||
switch reloadTarget {
|
switch reloadTarget {
|
||||||
case "nginx":
|
case "nginx":
|
||||||
return runCommand("nginx", "-s", "reload")
|
return reloadNginx()
|
||||||
case "xray":
|
case "xray":
|
||||||
return runCommand("systemctl", "restart", "xray")
|
return runCommand("systemctl", "restart", "xray")
|
||||||
case "both":
|
case "both":
|
||||||
if err := runCommand("nginx", "-s", "reload"); err != nil {
|
if err := reloadNginx(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return runCommand("systemctl", "restart", "xray")
|
return runCommand("systemctl", "restart", "xray")
|
||||||
@@ -2495,6 +2495,15 @@ func deployCertFiles(certPEM, keyPEM, certPath, keyPath, reloadTarget string) er
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func reloadNginx() error {
|
||||||
|
for _, bin := range []string{"/usr/local/nginx/sbin/nginx", "nginx"} {
|
||||||
|
if path, err := exec.LookPath(bin); err == nil {
|
||||||
|
return runCommand(path, "-s", "reload")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return runCommand("systemctl", "reload", "nginx")
|
||||||
|
}
|
||||||
|
|
||||||
func runCommand(name string, args ...string) error {
|
func runCommand(name string, args ...string) error {
|
||||||
if output, err := exec.Command(name, args...).CombinedOutput(); err != nil {
|
if output, err := exec.Command(name, args...).CombinedOutput(); err != nil {
|
||||||
return fmt.Errorf("%s: %s: %w", name, string(output), err)
|
return fmt.Errorf("%s: %s: %w", name, string(output), err)
|
||||||
|
|||||||
Reference in New Issue
Block a user