From 131a9aeefe2d75996454116e16d946a3f9a8da8b Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Fri, 4 Nov 2022 10:13:17 -0400 Subject: [PATCH] change job run time --- web/job/check_clinet_ip_job.go | 17 +---------------- web/web.go | 4 ++-- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/web/job/check_clinet_ip_job.go b/web/job/check_clinet_ip_job.go index e9ec6886..e3396ad6 100644 --- a/web/job/check_clinet_ip_job.go +++ b/web/job/check_clinet_ip_job.go @@ -104,7 +104,7 @@ func processLogFile() { // check if inbound connection is more than limited ip and drop connection LimitDevice := func() { LimitDevice() } - stop := schedule(LimitDevice, 1000 *time.Millisecond) + stop := schedule(LimitDevice, 700 *time.Millisecond) time.Sleep(60 * time.Second) stop <- true @@ -213,21 +213,6 @@ func GetInboundByEmail(clientEmail string) (*model.Inbound, error) { return inbounds, nil } -func DisableInbound(id int) error { - db := database.GetDB() - result := db.Model(model.Inbound{}). - Where("id = ? and enable = ?", id, true). - Update("enable", false) - err := result.Error - logger.Warning("disable inbound with id:",id) - - if err == nil { - job.xrayService.SetToNeedRestart() - } - - return err -} - func LimitDevice(){ localIp,err := LocalIP() diff --git a/web/web.go b/web/web.go index 60a69da1..0793a390 100644 --- a/web/web.go +++ b/web/web.go @@ -296,8 +296,8 @@ func (s *Server) startTask() { // 每 30 秒检查一次 inbound 流量超出和到期的情况 s.cron.AddJob("@every 30s", job.NewCheckInboundJob()) - // check client ips from log file every 1 min - s.cron.AddJob("@every 1m", job.NewCheckClientIpJob()) + // check client ips from log file every 30 sec + s.cron.AddJob("@every 30s", job.NewCheckClientIpJob()) // 每一天提示一次流量情况,上海时间8点30 var entry cron.EntryID