mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-16 20:27:08 +03:00
Fix: Invoke service.StopBot() in signal handlers (#3583)
Some checks failed
Release 3X-UI / build (386) (push) Has been cancelled
Release 3X-UI / build (amd64) (push) Has been cancelled
Release 3X-UI / build (arm64) (push) Has been cancelled
Release 3X-UI / build (armv5) (push) Has been cancelled
Release 3X-UI / build (armv6) (push) Has been cancelled
Release 3X-UI / build (armv7) (push) Has been cancelled
Release 3X-UI / build (s390x) (push) Has been cancelled
Release 3X-UI / Build for Windows (amd64) (push) Has been cancelled
Some checks failed
Release 3X-UI / build (386) (push) Has been cancelled
Release 3X-UI / build (amd64) (push) Has been cancelled
Release 3X-UI / build (arm64) (push) Has been cancelled
Release 3X-UI / build (armv5) (push) Has been cancelled
Release 3X-UI / build (armv6) (push) Has been cancelled
Release 3X-UI / build (armv7) (push) Has been cancelled
Release 3X-UI / build (s390x) (push) Has been cancelled
Release 3X-UI / Build for Windows (amd64) (push) Has been cancelled
Ensures the global Telegram bot stop function (`service.StopBot()`) is called upon receiving system signals (SIGHUP for restart, SIGINT/SIGTERM for shutdown). This complements the changes in `tgbot.go` to guarantee a clean shutdown of the Telegram bot's Long Polling operation, fully resolving the 409 Conflict issue during panel restarts or shutdowns. Changes: - Added `service.StopBot()` call to the `syscall.SIGHUP` handler. - Added `service.StopBot()` call to the default shutdown handler.
This commit is contained in:
8
main.go
8
main.go
@@ -78,6 +78,10 @@ func runWebServer() {
|
|||||||
case syscall.SIGHUP:
|
case syscall.SIGHUP:
|
||||||
logger.Info("Received SIGHUP signal. Restarting servers...")
|
logger.Info("Received SIGHUP signal. Restarting servers...")
|
||||||
|
|
||||||
|
// --- FIX FOR TELEGRAM BOT CONFLICT (409): Stop bot before restart ---
|
||||||
|
service.StopBot()
|
||||||
|
// --
|
||||||
|
|
||||||
err := server.Stop()
|
err := server.Stop()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Debug("Error stopping web server:", err)
|
logger.Debug("Error stopping web server:", err)
|
||||||
@@ -106,6 +110,10 @@ func runWebServer() {
|
|||||||
log.Println("Sub server restarted successfully.")
|
log.Println("Sub server restarted successfully.")
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
// --- FIX FOR TELEGRAM BOT CONFLICT (409) on full shutdown ---
|
||||||
|
service.StopBot()
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
|
||||||
server.Stop()
|
server.Stop()
|
||||||
subServer.Stop()
|
subServer.Stop()
|
||||||
log.Println("Shutting down servers.")
|
log.Println("Shutting down servers.")
|
||||||
|
|||||||
Reference in New Issue
Block a user