feat(watchdog): improve watchdog instance tracking
- Add Close() function to watchdog for graceful shutdown - Update instance message format for better consistency - Add watchdog status tracking in StatusInfo - Include watchdog field in FrpcInstance struct and database - Change port fields from string to int in FrpcProxyInfo - Add auth_token support in InstanceInfo
This commit is contained in:
@@ -31,7 +31,8 @@ var softwareInfo SoftwareInfo = SoftwareInfo{
|
||||
}
|
||||
|
||||
type StatusInfo struct {
|
||||
Status string
|
||||
ServerStatus string
|
||||
WatchdogStatus string
|
||||
}
|
||||
|
||||
type Is struct {
|
||||
@@ -84,7 +85,7 @@ func main() {
|
||||
postLog.Info("Database initialized successfully")
|
||||
|
||||
if err := InitFrpcDatabase(*dbPath_data); err != nil {
|
||||
postLog.Warning(fmt.Sprintf("Failed to initialize frpc database: %v", err))
|
||||
postLog.Fatal(fmt.Sprintf("Failed to initialize frpc database: %v", err))
|
||||
}
|
||||
|
||||
frpLogger.SetDatabase(db, frpcDB)
|
||||
@@ -154,15 +155,25 @@ func main() {
|
||||
postLog.Error(fmt.Sprintf("Error closing frpc database: %v", err))
|
||||
}
|
||||
|
||||
watchdog.Close()
|
||||
|
||||
postLog.Info("Server stopped")
|
||||
}
|
||||
|
||||
func GetStatusHandler(w http.ResponseWriter, r *http.Request) {
|
||||
statusInfo := StatusInfo{
|
||||
Status: "Online",
|
||||
ServerStatus: "Offline",
|
||||
WatchdogStatus: "Offline",
|
||||
}
|
||||
if !is.online {
|
||||
statusInfo.Status = "Offline"
|
||||
statusInfo.ServerStatus = "Offline"
|
||||
} else {
|
||||
statusInfo.ServerStatus = "Online"
|
||||
}
|
||||
if !is.watchdogConnected {
|
||||
statusInfo.WatchdogStatus = "Offline"
|
||||
} else {
|
||||
statusInfo.WatchdogStatus = "Online"
|
||||
}
|
||||
SendSuccessResponse(w, "getStatus", statusInfo)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user