mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
fix(docker): nginx restart always output network error
This commit is contained in:
parent
070c0b4620
commit
45a68112b1
5 changed files with 113 additions and 94 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func Reload(c *gin.Context) {
|
||||
|
@ -23,9 +24,24 @@ func Test(c *gin.Context) {
|
|||
}
|
||||
|
||||
func Restart(c *gin.Context) {
|
||||
output := nginx.Restart()
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": output,
|
||||
"level": nginx.GetLogLevel(output),
|
||||
"message": "ok",
|
||||
})
|
||||
go nginx.Restart()
|
||||
}
|
||||
|
||||
func Status(c *gin.Context) {
|
||||
pidPath := nginx.GetPIDPath()
|
||||
lastOutput := nginx.GetLastOutput()
|
||||
|
||||
running := true
|
||||
if fileInfo, err := os.Stat(pidPath); err != nil || fileInfo.Size() == 0 { // fileInfo.Size() == 0 no process id
|
||||
running = false
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"running": running,
|
||||
"message": lastOutput,
|
||||
"level": nginx.GetLogLevel(lastOutput),
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue