mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-19 08:23:03 +00:00
windows: error filter
This commit is contained in:
parent
6d41320ed7
commit
46de886b53
2 changed files with 18 additions and 1 deletions
|
@ -2,6 +2,7 @@ package xray
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"x-ui/logger"
|
"x-ui/logger"
|
||||||
|
@ -20,6 +21,12 @@ func (lw *LogWriter) Write(m []byte) (n int, err error) {
|
||||||
|
|
||||||
// Convert the data to a string
|
// Convert the data to a string
|
||||||
message := strings.TrimSpace(string(m))
|
message := strings.TrimSpace(string(m))
|
||||||
|
msgLowerAll := strings.ToLower(message)
|
||||||
|
|
||||||
|
// Suppress noisy Windows process-kill signal that surfaces as exit status 1
|
||||||
|
if runtime.GOOS == "windows" && strings.Contains(msgLowerAll, "exit status 1") {
|
||||||
|
return len(m), nil
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the message contains a crash
|
// Check if the message contains a crash
|
||||||
if crashRegex.MatchString(message) {
|
if crashRegex.MatchString(message) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -224,6 +225,15 @@ func (p *process) Start() (err error) {
|
||||||
go func() {
|
go func() {
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// On Windows, killing the process results in "exit status 1" which isn't an error for us
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
errStr := strings.ToLower(err.Error())
|
||||||
|
if strings.Contains(errStr, "exit status 1") {
|
||||||
|
// Suppress noisy log on graceful stop
|
||||||
|
p.exitErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
logger.Error("Failure in running xray-core:", err)
|
logger.Error("Failure in running xray-core:", err)
|
||||||
p.exitErr = err
|
p.exitErr = err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue