fix windows signal

This commit is contained in:
Alireza Ahmadi
2026-02-20 01:31:33 +01:00
parent 5b6daf9e70
commit 322a74429d
4 changed files with 14 additions and 2 deletions

View File

@@ -16,6 +16,7 @@ import (
"github.com/alireza0/x-ui/database"
"github.com/alireza0/x-ui/logger"
"github.com/alireza0/x-ui/sub"
"github.com/alireza0/x-ui/util/sys"
"github.com/alireza0/x-ui/web"
"github.com/alireza0/x-ui/web/global"
"github.com/alireza0/x-ui/web/service"
@@ -67,7 +68,7 @@ func runWebServer() {
sigCh := make(chan os.Signal, 1)
// Trap shutdown signals
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGUSR1)
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM, sys.SIGUSR1)
for {
sig := <-sigCh
@@ -98,7 +99,7 @@ func runWebServer() {
log.Println(err)
return
}
case syscall.SIGUSR1:
case sys.SIGUSR1:
logger.Info("Received USR1 signal, restarting xray-core...")
err := server.RestartXray()
if err != nil {

View File

@@ -4,9 +4,13 @@
package sys
import (
"syscall"
"github.com/shirou/gopsutil/v4/net"
)
var SIGUSR1 = syscall.SIGUSR1
func GetTCPCount() (int, error) {
stats, err := net.Connections("tcp")
if err != nil {

View File

@@ -8,8 +8,11 @@ import (
"fmt"
"io"
"os"
"syscall"
)
var SIGUSR1 = syscall.SIGUSR1
func getLinesNum(filename string) (int, error) {
file, err := os.Open(filename)
if err != nil {

View File

@@ -4,9 +4,13 @@
package sys
import (
"syscall"
"github.com/shirou/gopsutil/v4/net"
)
var SIGUSR1 = syscall.Signal(0)
func GetTCPCount() (int, error) {
stats, err := net.Connections("tcp")
if err != nil {