renamed func

This commit is contained in:
fgsfds 2025-08-07 23:31:57 +05:00
parent a72c86d0f3
commit ea6acda451
No known key found for this signature in database
GPG key ID: 264C1B9113012917
2 changed files with 6 additions and 4 deletions

View file

@ -16,7 +16,7 @@ func NewCheckXrayRunningJob() *CheckXrayRunningJob {
} }
func (j *CheckXrayRunningJob) Run() { func (j *CheckXrayRunningJob) Run() {
if !j.xrayService.IsNeedToResurrect() { if !j.xrayService.DidXrayCrash() {
j.checkTime = 0 j.checkTime = 0
} else { } else {
j.checkTime++ j.checkTime++

View file

@ -16,7 +16,7 @@ var (
p *xray.Process p *xray.Process
lock sync.Mutex lock sync.Mutex
isNeedXrayRestart atomic.Bool // Indicates that restart was requested for Xray isNeedXrayRestart atomic.Bool // Indicates that restart was requested for Xray
isManuallyStopped atomic.Bool // Indicates that Xray was stopped manually (i.e. didn't crash) isManuallyStopped atomic.Bool // Indicates that Xray was stopped manually from the panel
result string result string
) )
@ -39,6 +39,7 @@ func (s *XrayService) GetXrayErr() error {
if runtime.GOOS == "windows" && err.Error() == "exit status 1" { if runtime.GOOS == "windows" && err.Error() == "exit status 1" {
// exit status 1 on Windows means that Xray process was killed // exit status 1 on Windows means that Xray process was killed
// as we kill process to stop in on Windows, this is not an error
return nil return nil
} }
@ -60,6 +61,7 @@ func (s *XrayService) GetXrayResult() string {
if runtime.GOOS == "windows" && result == "exit status 1" { if runtime.GOOS == "windows" && result == "exit status 1" {
// exit status 1 on Windows means that Xray process was killed // exit status 1 on Windows means that Xray process was killed
// as we kill process to stop in on Windows, this is not an error
return "" return ""
} }
@ -246,7 +248,7 @@ func (s *XrayService) IsNeedRestartAndSetFalse() bool {
return isNeedXrayRestart.CompareAndSwap(true, false) return isNeedXrayRestart.CompareAndSwap(true, false)
} }
// Check if Xray is not running and wasn't stopped manually // Check if Xray is not running and wasn't stopped manually, i.e. crashed
func (s *XrayService) IsNeedToResurrect() bool { func (s *XrayService) DidXrayCrash() bool {
return !s.IsXrayRunning() && !isManuallyStopped.Load() return !s.IsXrayRunning() && !isManuallyStopped.Load()
} }