mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-13 03:15:48 +02:00
feat: inspect configurations #69
This commit is contained in:
parent
561771cf10
commit
768da42e35
23 changed files with 346 additions and 144 deletions
|
@ -1,40 +1,30 @@
|
|||
package nginx
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/0xJacky/Nginx-UI/server/settings"
|
||||
"log"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func TestConf() error {
|
||||
func TestConf() string {
|
||||
out, err := exec.Command("nginx", "-t").CombinedOutput()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
log.Println("[error] nginx.TestConf", err)
|
||||
}
|
||||
output := string(out)
|
||||
if strings.Contains(output, "failed") {
|
||||
return errors.New(output)
|
||||
}
|
||||
return nil
|
||||
|
||||
return string(out)
|
||||
}
|
||||
|
||||
func Reload() string {
|
||||
out, err := exec.Command("nginx", "-s", "reload").CombinedOutput()
|
||||
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return err.Error()
|
||||
log.Println("[error] nginx.Reload", err)
|
||||
}
|
||||
|
||||
output := string(out)
|
||||
if strings.Contains(output, "failed") {
|
||||
return output
|
||||
}
|
||||
return ""
|
||||
return string(out)
|
||||
}
|
||||
|
||||
func GetConfPath(dir ...string) string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue