mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-12 19:05:55 +02:00
refactor: use zap as logger ⚡
This commit is contained in:
parent
2831208de3
commit
f305701b30
34 changed files with 327 additions and 175 deletions
|
@ -1,8 +1,8 @@
|
|||
package nginx
|
||||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/logger"
|
||||
"github.com/0xJacky/Nginx-UI/server/settings"
|
||||
"log"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
@ -11,7 +11,7 @@ import (
|
|||
func TestConf() string {
|
||||
out, err := exec.Command("nginx", "-t").CombinedOutput()
|
||||
if err != nil {
|
||||
log.Println("[error] nginx.TestConf", err)
|
||||
logger.Error(err)
|
||||
}
|
||||
|
||||
return string(out)
|
||||
|
@ -21,7 +21,7 @@ func Reload() string {
|
|||
out, err := exec.Command("nginx", "-s", "reload").CombinedOutput()
|
||||
|
||||
if err != nil {
|
||||
log.Println("[error] nginx.Reload", err)
|
||||
logger.Error(err)
|
||||
}
|
||||
|
||||
return string(out)
|
||||
|
@ -31,7 +31,7 @@ func Restart() string {
|
|||
out, err := exec.Command("nginx", "-s", "reopen").CombinedOutput()
|
||||
|
||||
if err != nil {
|
||||
log.Println("[error] nginx.Restart", err)
|
||||
logger.Error(err)
|
||||
}
|
||||
|
||||
return string(out)
|
||||
|
@ -43,13 +43,13 @@ func GetConfPath(dir ...string) string {
|
|||
if settings.ServerSettings.NginxConfigDir == "" {
|
||||
out, err := exec.Command("nginx", "-V").CombinedOutput()
|
||||
if err != nil {
|
||||
log.Println("nginx.GetConfPath exec.Command error", err)
|
||||
logger.Error(err)
|
||||
return ""
|
||||
}
|
||||
r, _ := regexp.Compile("--conf-path=(.*)/(.*.conf)")
|
||||
match := r.FindStringSubmatch(string(out))
|
||||
if len(match) < 1 {
|
||||
log.Println("nginx.GetConfPath len(match) < 1")
|
||||
logger.Error("nginx.GetConfPath len(match) < 1")
|
||||
return ""
|
||||
}
|
||||
confPath = r.FindStringSubmatch(string(out))[1]
|
||||
|
@ -66,13 +66,13 @@ func GetNginxPIDPath() string {
|
|||
if settings.ServerSettings.NginxPIDPath == "" {
|
||||
out, err := exec.Command("nginx", "-V").CombinedOutput()
|
||||
if err != nil {
|
||||
log.Println("nginx.GetNginxPIDPath exec.Command error", err)
|
||||
logger.Error(err)
|
||||
return ""
|
||||
}
|
||||
r, _ := regexp.Compile("--pid-path=(.*.pid)")
|
||||
match := r.FindStringSubmatch(string(out))
|
||||
if len(match) < 1 {
|
||||
log.Println("nginx.GetNginxPIDPath len(match) < 1")
|
||||
logger.Error("nginx.GetNginxPIDPath len(match) < 1")
|
||||
return ""
|
||||
}
|
||||
confPath = r.FindStringSubmatch(string(out))[1]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue