Довёл fix20: firewall-mode, staged state, diagnostics, readiness и build-gate

This commit is contained in:
2026-05-07 23:38:55 +05:00
parent 0a8f4e0c3d
commit 4b382d6ef9
25 changed files with 840 additions and 133 deletions
+14
View File
@@ -226,6 +226,20 @@ func CloseSqliteDB() error {
return nil
}
func IsSqliteReady() bool {
if sqliteDB == nil {
return false
}
db, err := sqliteDB.DB()
if err != nil {
return false
}
if err := db.Ping(); err != nil {
return false
}
return true
}
func Paginate(pageNum *int64, pageSize *int64) func(db *gorm.DB) *gorm.DB {
var num int64 = 1
var size int64 = 10
+28
View File
@@ -2,12 +2,40 @@ package router
import (
"github.com/gin-gonic/gin"
"hy2xs-admin/dao"
"hy2xs-admin/frontend"
"hy2xs-admin/middleware"
"hy2xs-admin/model/constant"
"os"
"strings"
)
func Router(router *gin.Engine, huiWebContext *string) {
router.GET("/healthz", func(c *gin.Context) {
sqliteReady := dao.IsSqliteReady()
configReadable := false
if stat, err := os.Stat(constant.Hysteria2ConfigPath); err == nil {
configReadable = !stat.IsDir()
}
if !sqliteReady || !configReadable {
c.JSON(503, gin.H{
"ok": false,
"service": "hy2xs-admin",
"sqlite_ready": sqliteReady,
"config_readable": configReadable,
})
return
}
c.JSON(200, gin.H{
"ok": true,
"service": "hy2xs-admin",
"sqlite_ready": true,
"config_readable": true,
})
})
relativePath := "/"
if huiWebContext != nil && strings.HasPrefix(*huiWebContext, "/") {
relativePath = *huiWebContext