mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 18:35:51 +02:00
fix: update Dockerfile and init-nginx.sh for improved nginx control error handling
This commit is contained in:
parent
a4c11d521d
commit
855c3375f8
3 changed files with 59 additions and 7 deletions
|
@ -5,14 +5,16 @@ 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, err := nginx.Reload()
|
||||
if err != nil {
|
||||
cosy.ErrHandler(c, err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": output + err.Error(),
|
||||
"level": nginx.GetLogLevel(output),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
|
@ -25,7 +27,10 @@ func Reload(c *gin.Context) {
|
|||
func TestConfig(c *gin.Context) {
|
||||
output, err := nginx.TestConfig()
|
||||
if err != nil {
|
||||
cosy.ErrHandler(c, err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": output + err.Error(),
|
||||
"level": nginx.GetLogLevel(output),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
|
@ -46,7 +51,10 @@ func Restart(c *gin.Context) {
|
|||
func Status(c *gin.Context) {
|
||||
lastOutput, err := nginx.GetLastOutput()
|
||||
if err != nil {
|
||||
cosy.ErrHandler(c, err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": lastOutput + err.Error(),
|
||||
"level": nginx.GetLogLevel(lastOutput),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue