Skip to content

Commit

Permalink
Merge pull request #10 from kutovoys/stability
Browse files Browse the repository at this point in the history
Fixed KillXray function: added process termination wait using cmd.Wait() to prevent accumulation of hanging Xray processes.
  • Loading branch information
kutovoys authored Sep 10, 2024
2 parents 8cde41e + 0555048 commit 771e8f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ func processConfigFile(configPath string, provider models.Provider) {
utils.LogResult(logData)
return
}

defer utils.KillXray(cmd)

time.Sleep(4 * time.Second)

proxyClient, err := utils.CreateProxyClient(logData.ProxyAddress)
Expand Down
5 changes: 4 additions & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ func RunXray(configPath string) (*exec.Cmd, error) {
}

func KillXray(cmd *exec.Cmd) error {
return cmd.Process.Kill()
if err := cmd.Process.Kill(); err != nil {
return err
}
return cmd.Wait()
}

func CreateProxyClient(proxyAddress string) (*http.Client, error) {
Expand Down

0 comments on commit 771e8f9

Please sign in to comment.