1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-03-14 17:54:44 +08:00
1Panel/backend/server/server.go

59 lines
1.2 KiB
Go
Raw Normal View History

2022-08-16 23:30:23 +08:00
package server
import (
"net"
"net/http"
"github.com/1Panel-dev/1Panel/backend/i18n"
2022-11-21 11:27:56 +08:00
"github.com/1Panel-dev/1Panel/backend/init/app"
2022-11-23 17:44:24 +08:00
"github.com/1Panel-dev/1Panel/backend/init/business"
"github.com/1Panel-dev/1Panel/backend/cron"
2022-08-16 23:30:23 +08:00
"github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/backend/init/db"
2023-02-02 15:01:37 +08:00
"github.com/1Panel-dev/1Panel/backend/init/hook"
"github.com/1Panel-dev/1Panel/backend/init/log"
"github.com/1Panel-dev/1Panel/backend/init/migration"
"github.com/1Panel-dev/1Panel/backend/init/router"
"github.com/1Panel-dev/1Panel/backend/init/validator"
"github.com/1Panel-dev/1Panel/backend/init/viper"
2022-08-16 23:30:23 +08:00
"github.com/gin-gonic/gin"
)
func Start() {
viper.Init()
2024-02-19 13:55:27 +08:00
i18n.Init()
2022-08-16 23:30:23 +08:00
log.Init()
db.Init()
migration.Init()
app.Init()
2022-08-16 23:30:23 +08:00
validator.Init()
gin.SetMode("debug")
2022-09-08 11:39:14 +08:00
cron.Run()
InitOthers()
2022-11-23 17:44:24 +08:00
business.Init()
hook.Init()
2022-08-17 15:01:56 +08:00
rootRouter := router.Routers()
server := &http.Server{
2024-07-22 16:14:59 +08:00
Addr: ":9999",
Handler: rootRouter,
}
2024-07-22 16:14:59 +08:00
ln, err := net.Listen("tcp4", ":9999")
if err != nil {
panic(err)
}
type tcpKeepAliveListener struct {
*net.TCPListener
}
2024-07-22 16:14:59 +08:00
global.LOG.Info("listen at http://0.0.0.0:9999")
if err := server.Serve(tcpKeepAliveListener{ln.(*net.TCPListener)}); err != nil {
panic(err)
}
2022-08-16 23:30:23 +08:00
}