mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat(wip): docker ui only
This commit is contained in:
parent
c62fd25b2e
commit
d4a4ed1e1c
43 changed files with 1269 additions and 372 deletions
|
@ -74,7 +74,12 @@ func AddConfig(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
output := nginx.Reload()
|
||||
output, err := nginx.Reload()
|
||||
if err != nil {
|
||||
cosy.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
if nginx.GetLogLevel(output) >= nginx.Warn {
|
||||
cosy.ErrHandler(c, cosy.WrapErrorWithParams(config.ErrNginxReloadFailed, output))
|
||||
return
|
||||
|
|
|
@ -5,24 +5,36 @@ import (
|
|||
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/uozi-tech/cosy"
|
||||
)
|
||||
|
||||
// Reload reloads the nginx
|
||||
func Reload(c *gin.Context) {
|
||||
output := nginx.Reload()
|
||||
output, err := nginx.Reload()
|
||||
if err != nil {
|
||||
cosy.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": output,
|
||||
"level": nginx.GetLogLevel(output),
|
||||
})
|
||||
}
|
||||
|
||||
func Test(c *gin.Context) {
|
||||
output := nginx.TestConf()
|
||||
// TestConfig tests the nginx config
|
||||
func TestConfig(c *gin.Context) {
|
||||
output, err := nginx.TestConfig()
|
||||
if err != nil {
|
||||
cosy.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": output,
|
||||
"level": nginx.GetLogLevel(output),
|
||||
})
|
||||
}
|
||||
|
||||
// Restart restarts the nginx
|
||||
func Restart(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "ok",
|
||||
|
@ -30,8 +42,13 @@ func Restart(c *gin.Context) {
|
|||
go nginx.Restart()
|
||||
}
|
||||
|
||||
// Status returns the status of the nginx
|
||||
func Status(c *gin.Context) {
|
||||
lastOutput := nginx.GetLastOutput()
|
||||
lastOutput, err := nginx.GetLastOutput()
|
||||
if err != nil {
|
||||
cosy.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
running := nginx.IsNginxRunning()
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ func InitRouter(r *gin.RouterGroup) {
|
|||
r.POST("ngx/format_code", FormatNginxConfig)
|
||||
r.POST("nginx/reload", Reload)
|
||||
r.POST("nginx/restart", Restart)
|
||||
r.POST("nginx/test", Test)
|
||||
r.POST("nginx/test", TestConfig)
|
||||
r.GET("nginx/status", Status)
|
||||
// Get detailed Nginx status information, including connection count, process information, etc. (Issue #850)
|
||||
r.GET("nginx/detail_status", GetDetailStatus)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
package nginx
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -119,10 +118,14 @@ func ToggleStubStatus(c *gin.Context) {
|
|||
}
|
||||
|
||||
// Reload Nginx configuration
|
||||
reloadOutput := nginx.Reload()
|
||||
reloadOutput, err := nginx.Reload()
|
||||
if err != nil {
|
||||
cosy.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
if len(reloadOutput) > 0 && (strings.Contains(strings.ToLower(reloadOutput), "error") ||
|
||||
strings.Contains(strings.ToLower(reloadOutput), "failed")) {
|
||||
cosy.ErrHandler(c, errors.New("Reload Nginx failed"))
|
||||
cosy.ErrHandler(c, cosy.WrapErrorWithParams(nginx.ErrReloadFailed, reloadOutput))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue