From be4a68bd8bbd0a79e8195a3e1dd73062e9c1663a Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Wed, 6 Sep 2023 18:22:37 +0330 Subject: move restart cron to web.go Co-Authored-By: Alireza Ahmadi --- web/controller/inbound.go | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'web/controller') diff --git a/web/controller/inbound.go b/web/controller/inbound.go index 219f1211..8b64fe6e 100644 --- a/web/controller/inbound.go +++ b/web/controller/inbound.go @@ -4,8 +4,6 @@ import ( "fmt" "strconv" "x-ui/database/model" - "x-ui/logger" - "x-ui/web/global" "x-ui/web/service" "x-ui/web/session" @@ -20,7 +18,6 @@ type InboundController struct { func NewInboundController(g *gin.RouterGroup) *InboundController { a := &InboundController{} a.initRouter(g) - a.startTask() return a } @@ -42,19 +39,6 @@ func (a *InboundController) initRouter(g *gin.RouterGroup) { g.POST("/delDepletedClients/:id", a.delDepletedClients) } -func (a *InboundController) startTask() { - webServer := global.GetWebServer() - c := webServer.GetCron() - c.AddFunc("@every 10s", func() { - if a.xrayService.IsNeedRestartAndSetFalse() { - err := a.xrayService.RestartXray(false) - if err != nil { - logger.Error("restart xray failed:", err) - } - } - }) -} - func (a *InboundController) getInbounds(c *gin.Context) { user := session.GetLoginUser(c) inbounds, err := a.inboundService.GetInbounds(user.Id) -- cgit v1.2.3