Skip to content

Commit

Permalink
feat: add setting for test nginx config command #191
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJacky committed Nov 21, 2023
1 parent ba4aeb8 commit 3ee8ef0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ AccessLogPath = /var/log/nginx/access.log
ErrorLogPath = /var/log/nginx/error.log
ConfigDir =
PIDPath =
TestConfigCmd =
ReloadCmd =
RestartCmd =

Expand Down
11 changes: 11 additions & 0 deletions server/internal/nginx/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions server/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down

0 comments on commit 3ee8ef0

Please sign in to comment.