mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-08-23 19:36:54 +00:00

Some checks are pending
Release 3X-UI / build (386) (push) Waiting to run
Release 3X-UI / build (amd64) (push) Waiting to run
Release 3X-UI / build (arm64) (push) Waiting to run
Release 3X-UI / build (armv5) (push) Waiting to run
Release 3X-UI / build (armv6) (push) Waiting to run
Release 3X-UI / build (armv7) (push) Waiting to run
Release 3X-UI / build (s390x) (push) Waiting to run
32 lines
565 B
Go
32 lines
565 B
Go
package job
|
|
|
|
import (
|
|
"x-ui/logger"
|
|
"x-ui/web/service"
|
|
)
|
|
|
|
type CheckXrayRunningJob struct {
|
|
xrayService service.XrayService
|
|
|
|
checkTime int
|
|
}
|
|
|
|
func NewCheckXrayRunningJob() *CheckXrayRunningJob {
|
|
return new(CheckXrayRunningJob)
|
|
}
|
|
|
|
func (j *CheckXrayRunningJob) Run() {
|
|
if !j.xrayService.DidXrayCrash() {
|
|
j.checkTime = 0
|
|
} else {
|
|
j.checkTime++
|
|
// only restart if it's down 2 times in a row
|
|
if j.checkTime > 1 {
|
|
err := j.xrayService.RestartXray(false)
|
|
j.checkTime = 0
|
|
if err != nil {
|
|
logger.Error("Restart xray failed:", err)
|
|
}
|
|
}
|
|
}
|
|
}
|