feat: added status check and control functions for the Nginx stub_status module and optimized the performance data acquisition logic

This commit is contained in:
Akino 2025-04-10 10:11:26 +00:00
parent 32d7c74835
commit 2d0961f1a3
No known key found for this signature in database
GPG key ID: FB2F74D193A40907
16 changed files with 720 additions and 543 deletions

View file

@ -1,10 +1,10 @@
package nginx
import (
"net/http"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/gin-gonic/gin"
"net/http"
"os"
)
func Reload(c *gin.Context) {
@ -31,13 +31,9 @@ func Restart(c *gin.Context) {
}
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
}
running := nginx.IsNginxRunning()
c.JSON(http.StatusOK, gin.H{
"running": running,