Skip to content

Commit 3ee8ef0

Browse files
committed
feat: add setting for test nginx config command #191
1 parent ba4aeb8 commit 3ee8ef0

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

app.example.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ AccessLogPath = /var/log/nginx/access.log
1414
ErrorLogPath = /var/log/nginx/error.log
1515
ConfigDir =
1616
PIDPath =
17+
TestConfigCmd =
1718
ReloadCmd =
1819
RestartCmd =
1920

server/internal/nginx/nginx.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ func execShell(cmd string) (out string, err error) {
1515
}
1616

1717
func TestConf() (string, error) {
18+
if settings.NginxSettings.TestConfigCmd != "" {
19+
out, err := execShell(settings.NginxSettings.TestConfigCmd)
20+
21+
if err != nil {
22+
logger.Error(err)
23+
return out, err
24+
}
25+
26+
return out, nil
27+
}
28+
1829
out, err := exec.Command("nginx", "-t").CombinedOutput()
1930
if err != nil {
2031
logger.Error(err)

server/settings/settings.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type Nginx struct {
3636
ErrorLogPath string `json:"error_log_path"`
3737
ConfigDir string `json:"config_dir"`
3838
PIDPath string `json:"pid_path"`
39+
TestConfigCmd string `json:"test_config_cmd"`
3940
ReloadCmd string `json:"reload_cmd"`
4041
RestartCmd string `json:"restart_cmd"`
4142
}

0 commit comments

Comments
 (0)