feat: change gin start mode (#10885)

This commit is contained in:
CityFun 2025-11-07 16:34:30 +08:00 committed by GitHub
parent f4f6f65b4c
commit 009237a35a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 7 deletions

View file

@ -4,6 +4,7 @@ import (
"crypto/tls" "crypto/tls"
"crypto/x509" "crypto/x509"
"fmt" "fmt"
"github.com/gin-gonic/gin"
"net" "net"
"net/http" "net/http"
"os" "os"
@ -26,7 +27,6 @@ import (
"github.com/1Panel-dev/1Panel/agent/init/validator" "github.com/1Panel-dev/1Panel/agent/init/validator"
"github.com/1Panel-dev/1Panel/agent/init/viper" "github.com/1Panel-dev/1Panel/agent/init/viper"
"github.com/1Panel-dev/1Panel/agent/utils/encrypt" "github.com/1Panel-dev/1Panel/agent/utils/encrypt"
"github.com/gin-gonic/gin"
) )
func Start() { func Start() {
@ -40,7 +40,6 @@ func Start() {
app.Init() app.Init()
lang.Init() lang.Init()
validator.Init() validator.Init()
gin.SetMode("debug")
cron.Run() cron.Run()
hook.Init() hook.Init()
InitOthers() InitOthers()
@ -51,6 +50,12 @@ func Start() {
Handler: rootRouter, Handler: rootRouter,
} }
if global.CONF.Base.Mode != "stable" {
gin.SetMode(gin.DebugMode)
} else {
gin.SetMode(gin.ReleaseMode)
}
if global.IsMaster { if global.IsMaster {
_ = os.Remove("/etc/1panel/agent.sock") _ = os.Remove("/etc/1panel/agent.sock")
_ = os.Mkdir("/etc/1panel", constant.DirPerm) _ = os.Mkdir("/etc/1panel", constant.DirPerm)

View file

@ -5,6 +5,7 @@ import (
"encoding/gob" "encoding/gob"
"fmt" "fmt"
"github.com/1Panel-dev/1Panel/core/init/proxy" "github.com/1Panel-dev/1Panel/core/init/proxy"
"github.com/gin-gonic/gin"
"net" "net"
"net/http" "net/http"
"os" "os"
@ -26,8 +27,6 @@ import (
"github.com/1Panel-dev/1Panel/core/init/session/psession" "github.com/1Panel-dev/1Panel/core/init/session/psession"
"github.com/1Panel-dev/1Panel/core/init/validator" "github.com/1Panel-dev/1Panel/core/init/validator"
"github.com/1Panel-dev/1Panel/core/init/viper" "github.com/1Panel-dev/1Panel/core/init/viper"
"github.com/gin-gonic/gin"
) )
func Start() { func Start() {
@ -41,7 +40,6 @@ func Start() {
gob.Register(psession.SessionUser{}) gob.Register(psession.SessionUser{})
cron.Init() cron.Init()
session.Init() session.Init()
gin.SetMode("debug")
hook.Init() hook.Init()
InitOthers() InitOthers()
@ -50,6 +48,12 @@ func Start() {
rootRouter := router.Routers() rootRouter := router.Routers()
if global.CONF.Base.Mode != "stable" {
gin.SetMode(gin.DebugMode)
} else {
gin.SetMode(gin.ReleaseMode)
}
tcpItem := "tcp4" tcpItem := "tcp4"
if global.CONF.Conn.Ipv6 == constant.StatusEnable { if global.CONF.Conn.Ipv6 == constant.StatusEnable {
tcpItem = "tcp" tcpItem = "tcp"

View file

@ -112,8 +112,8 @@
class="!w-24" class="!w-24"
> >
<el-option <el-option
v-for="(unit, index) in Units" v-for="(unit, indexKey) in Units"
:key="index" :key="indexKey"
:label="unit.label" :label="unit.label"
:value="unit.value" :value="unit.value"
/> />