feat: add setting for test nginx config command #191

This commit is contained in:
0xJacky 2023-11-21 15:58:53 +08:00
parent ba4aeb85ca
commit 3ee8ef0523
No known key found for this signature in database
GPG key ID: B6E4A6E4A561BAF0
3 changed files with 13 additions and 0 deletions

View file

@ -14,6 +14,7 @@ AccessLogPath = /var/log/nginx/access.log
ErrorLogPath = /var/log/nginx/error.log
ConfigDir =
PIDPath =
TestConfigCmd =
ReloadCmd =
RestartCmd =

View file

@ -15,6 +15,17 @@ func execShell(cmd string) (out string, err error) {
}
func TestConf() (string, error) {
if settings.NginxSettings.TestConfigCmd != "" {
out, err := execShell(settings.NginxSettings.TestConfigCmd)
if err != nil {
logger.Error(err)
return out, err
}
return out, nil
}
out, err := exec.Command("nginx", "-t").CombinedOutput()
if err != nil {
logger.Error(err)

View file

@ -36,6 +36,7 @@ type Nginx struct {
ErrorLogPath string `json:"error_log_path"`
ConfigDir string `json:"config_dir"`
PIDPath string `json:"pid_path"`
TestConfigCmd string `json:"test_config_cmd"`
ReloadCmd string `json:"reload_cmd"`
RestartCmd string `json:"restart_cmd"`
}