fix(user): allow re-login by removing existing session if user is already logged in

fix(main): conditionally initialize and connect to watchdog based on configuration

fix(instance): remove unused userID variable and commented debug logs in ListInstancesHandler
This commit is contained in:
2026-05-10 21:54:49 +08:00
parent a7d6bb0cb8
commit 5c748dafcd
4 changed files with 37 additions and 21 deletions
+16 -14
View File
@@ -73,23 +73,25 @@ func main() {
setupRoutes()
// Initialize watchdog connection
err = watchdog.Init()
if err != nil {
postLog.Error(fmt.Sprintf("Unable to initialize Watchdog: %s", err))
} else {
if !watchdog.Connect() {
postLog.Error("Failed to connect to Watchdog")
if global.CurrentConfig.Watchdog.Enabled {
err = watchdog.Init()
if err != nil {
postLog.Error(fmt.Sprintf("Unable to initialize Watchdog: %s", err))
} else {
postLog.Info("Connected to Watchdog successfully")
if !watchdog.Connect() {
postLog.Error("Failed to connect to Watchdog")
} else {
postLog.Info("Connected to Watchdog successfully")
go func() {
if err := watchdog.StartKeepAlive(); err != nil {
postLog.Error(fmt.Sprintf("Watchdog keepalive stopped: %v", err))
global.Is.WatchdogConnected = false
}
}()
go func() {
if err := watchdog.StartKeepAlive(); err != nil {
postLog.Error(fmt.Sprintf("Watchdog keepalive stopped: %v", err))
global.Is.WatchdogConnected = false
}
}()
}
}
}
}
addr := fmt.Sprintf("%s:%s", global.CurrentConfig.ListenAddr, global.CurrentConfig.ListenPort)
server := &http.Server{