fix: keep panel restarts from hanging on the CPU job and Telegram (#7029)

Restarting the panel left it unreachable for up to a minute. CheckCpuJob sampled cpu.Percent over its whole one-minute period, so cron.Stop nearly always waited on it; it now diffs cpu.Times against its previous run (iowait counted as idle, as before). With Telegram unreachable, bus.Stop waited on an in-flight send and tgbot.Start ran getMe/setMyCommands inline; each bot call now returns once StopBot closes the bot's stop channel, the bot stops before the bus, and the artwork/commands warm-up runs in the background.
This commit is contained in:
PluS98
2026-11-02 17:34:22 +03:00
committed by GitHub
parent 43af7ada96
commit 121123eaaa
8 changed files with 304 additions and 42 deletions
+4 -3
View File
@@ -814,6 +814,10 @@ func (s *Server) stop(stopXray bool, stopTgBot bool) error {
err2 = common.Combine(err2, err)
}
}
// Before the bus: its Telegram notifier may sit in a send only StopBot ends.
if stopTgBot && s.tgbotService.IsRunning() {
s.tgbotService.Stop()
}
if s.bus != nil {
s.bus.Stop()
}
@@ -823,9 +827,6 @@ func (s *Server) stop(stopXray bool, stopTgBot bool) error {
if stopXray {
service.StopTrafficWriter()
}
if stopTgBot && s.tgbotService.IsRunning() {
s.tgbotService.Stop()
}
if s.discordGateway != nil && s.discordGateway.IsRunning() {
s.discordGateway.Stop()
}