mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-02-27 20:53:01 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
91aad724c2
10 changed files with 32 additions and 1 deletions
9
main.go
9
main.go
|
|
@ -16,6 +16,7 @@ import (
|
|||
"github.com/mhsanaei/3x-ui/v2/logger"
|
||||
"github.com/mhsanaei/3x-ui/v2/sub"
|
||||
"github.com/mhsanaei/3x-ui/v2/util/crypto"
|
||||
"github.com/mhsanaei/3x-ui/v2/util/sys"
|
||||
"github.com/mhsanaei/3x-ui/v2/web"
|
||||
"github.com/mhsanaei/3x-ui/v2/web/global"
|
||||
"github.com/mhsanaei/3x-ui/v2/web/service"
|
||||
|
|
@ -70,7 +71,7 @@ func runWebServer() {
|
|||
|
||||
sigCh := make(chan os.Signal, 1)
|
||||
// Trap shutdown signals
|
||||
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM)
|
||||
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM, sys.SIGUSR1)
|
||||
for {
|
||||
sig := <-sigCh
|
||||
|
||||
|
|
@ -108,6 +109,12 @@ func runWebServer() {
|
|||
return
|
||||
}
|
||||
log.Println("Sub server restarted successfully.")
|
||||
case sys.SIGUSR1:
|
||||
logger.Info("Received USR1 signal, restarting xray-core...")
|
||||
err := server.RestartXray()
|
||||
if err != nil {
|
||||
logger.Error("Failed to restart xray-core:", err)
|
||||
}
|
||||
|
||||
default:
|
||||
// --- FIX FOR TELEGRAM BOT CONFLICT (409) on full shutdown ---
|
||||
|
|
|
|||
|
|
@ -7,11 +7,14 @@ import (
|
|||
"encoding/binary"
|
||||
"fmt"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
"github.com/shirou/gopsutil/v4/net"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var SIGUSR1 = syscall.SIGUSR1
|
||||
|
||||
func GetTCPCount() (int, error) {
|
||||
stats, err := net.Connections("tcp")
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,11 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var SIGUSR1 = syscall.SIGUSR1
|
||||
|
||||
func getLinesNum(filename string) (int, error) {
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import (
|
|||
"github.com/shirou/gopsutil/v4/net"
|
||||
)
|
||||
|
||||
var SIGUSR1 = syscall.Signal(0)
|
||||
|
||||
// GetConnectionCount returns the number of active connections for the specified protocol ("tcp" or "udp").
|
||||
func GetConnectionCount(proto string) (int, error) {
|
||||
if proto != "tcp" && proto != "udp" {
|
||||
|
|
|
|||
|
|
@ -490,3 +490,7 @@ func (s *Server) GetCron() *cron.Cron {
|
|||
func (s *Server) GetWSHub() any {
|
||||
return s.wsHub
|
||||
}
|
||||
|
||||
func (s *Server) RestartXray() error {
|
||||
return s.xrayService.RestartXray(true)
|
||||
}
|
||||
|
|
|
|||
5
x-ui.rc
5
x-ui.rc
|
|
@ -10,4 +10,9 @@ depend() {
|
|||
}
|
||||
start_pre(){
|
||||
cd /usr/local/x-ui
|
||||
}
|
||||
reload() {
|
||||
ebegin "Reloading ${RC_SVCNAME}"
|
||||
kill -USR1 $pidfile
|
||||
eend $?
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ Environment="XRAY_VMESS_AEAD_FORCED=false"
|
|||
Type=simple
|
||||
WorkingDirectory=/usr/lib/x-ui/
|
||||
ExecStart=/usr/lib/x-ui/x-ui
|
||||
ExecReload=kill -USR1 $MAINPID
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ Environment="XRAY_VMESS_AEAD_FORCED=false"
|
|||
Type=simple
|
||||
WorkingDirectory=/usr/local/x-ui/
|
||||
ExecStart=/usr/local/x-ui/x-ui
|
||||
ExecReload=kill -USR1 $MAINPID
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ Environment="XRAY_VMESS_AEAD_FORCED=false"
|
|||
Type=simple
|
||||
WorkingDirectory=/usr/local/x-ui/
|
||||
ExecStart=/usr/local/x-ui/x-ui
|
||||
ExecReload=kill -USR1 $MAINPID
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
|
||||
|
|
|
|||
4
x-ui.sh
4
x-ui.sh
|
|
@ -2394,6 +2394,7 @@ show_usage() {
|
|||
│ ${blue}x-ui start${plain} - Start │
|
||||
│ ${blue}x-ui stop${plain} - Stop │
|
||||
│ ${blue}x-ui restart${plain} - Restart │
|
||||
| ${blue}x-ui restart-xray${plain} - Restart Xray │
|
||||
│ ${blue}x-ui status${plain} - Current Status │
|
||||
│ ${blue}x-ui settings${plain} - Current Settings │
|
||||
│ ${blue}x-ui enable${plain} - Enable Autostart on OS Startup │
|
||||
|
|
@ -2561,6 +2562,9 @@ if [[ $# > 0 ]]; then
|
|||
"restart")
|
||||
check_install 0 && restart 0
|
||||
;;
|
||||
"restart-xray")
|
||||
check_install 0 && restart_xray 0
|
||||
;;
|
||||
"status")
|
||||
check_install 0 && status 0
|
||||
;;
|
||||
|
|
|
|||
Loading…
Reference in a new issue