mirror of
https://github.com/alireza0/x-ui.git
synced 2026-03-14 05:23:09 +00:00
move restart cron to web.go
This commit is contained in:
10
web/web.go
10
web/web.go
@@ -238,6 +238,16 @@ func (s *Server) startTask() {
|
||||
// Check whether xray is running every 30 seconds
|
||||
s.cron.AddJob("@every 30s", job.NewCheckXrayRunningJob())
|
||||
|
||||
// Check if xray needs to be restarted
|
||||
s.cron.AddFunc("@every 10s", func() {
|
||||
if s.xrayService.IsNeedRestartAndSetFalse() {
|
||||
err := s.xrayService.RestartXray(false)
|
||||
if err != nil {
|
||||
logger.Error("restart xray failed:", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
go func() {
|
||||
time.Sleep(time.Second * 5)
|
||||
// Statistics every 10 seconds, start the delay for 5 seconds for the first time, and staggered with the time to restart xray
|
||||
|
||||
Reference in New Issue
Block a user