mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 05:04:22 +00:00
- Update go.mod module path from mhsanaei/3x-ui/v3 to saeederamy/3x-ui/v3 - Update all 73 Go files' import paths accordingly - Fix README.fa_IR.md install command to point to fork's main branch The fork was referencing the original repo's module path in go.mod and all Go source imports, making it dependent on MHSanaei's namespace at build time. https://claude.ai/code/session_01M6d5atbWjuLTj6UwRHoK5m
36 lines
1 KiB
Go
36 lines
1 KiB
Go
// Package job provides background job implementations for the 3x-ui web panel,
|
|
// including traffic monitoring, system checks, and periodic maintenance tasks.
|
|
package job
|
|
|
|
import (
|
|
"github.com/saeederamy/3x-ui/v3/logger"
|
|
"github.com/saeederamy/3x-ui/v3/web/service"
|
|
)
|
|
|
|
// CheckXrayRunningJob monitors Xray process health and restarts it if it crashes.
|
|
type CheckXrayRunningJob struct {
|
|
xrayService service.XrayService
|
|
checkTime int
|
|
}
|
|
|
|
// NewCheckXrayRunningJob creates a new Xray health check job instance.
|
|
func NewCheckXrayRunningJob() *CheckXrayRunningJob {
|
|
return new(CheckXrayRunningJob)
|
|
}
|
|
|
|
// Run checks if Xray has crashed and restarts it after confirming it's down for 2 consecutive checks.
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
}
|