fix(instance): (systemd) fix when the instance is not running but the backend still says it's running
This commit is contained in:
@@ -635,13 +635,18 @@ func StartInstanceHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if is.watchdogConnected {
|
||||
if !watchdog.AddInstance(serviceName) {
|
||||
if err := IsInstanceRunning(instanceID); err != nil { // Check if instance is really running
|
||||
SendErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("Failed to start instance %d: %v", instanceID, err))
|
||||
postLog.Warning(fmt.Sprintf("[StartInstanceHandler] Instance %d may not be running: %v", instanceID, err))
|
||||
return
|
||||
}
|
||||
postLog.Warning(fmt.Sprintf("[StartInstanceHandler] Failed to add watchdog instance %s", serviceName))
|
||||
SendSuccessResponse(w, "Instance started successfully but watchdog instance add failed", nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err := IsInstanceRunning(instanceID); err != nil {
|
||||
if err := IsInstanceRunning(instanceID); err != nil { // Check if instance is really running
|
||||
SendErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("Failed to start instance %d: %v", instanceID, err))
|
||||
postLog.Warning(fmt.Sprintf("[StartInstanceHandler] Instance %d may not be running: %v", instanceID, err))
|
||||
return
|
||||
@@ -915,7 +920,7 @@ func GetInstanceStatusHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
SendSuccessResponse(w, "Instance status retrieved successfully", responseData)
|
||||
postLog.Info(fmt.Sprintf("[GetInstanceStatusHandler] Retrieved status for instance %d (name: %s), isRunning: %v", instanceID, instance.Name, responseData["isRunning"]))
|
||||
// postLog.Debug(fmt.Sprintf("[GetInstanceStatusHandler] Retrieved status for instance %d (name: %s), isRunning: %v", instanceID, instance.Name, responseData["isRunning"]))
|
||||
}
|
||||
|
||||
func GetInstanceInfoHandler(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -1010,5 +1015,5 @@ func GetInstanceInfoHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
SendSuccessResponse(w, "Instance info retrieved successfully", responseData)
|
||||
postLog.Info(fmt.Sprintf("[GetInstanceInfoHandler] Retrieved info for instance %d (name: %s), userType: %s", instanceID, instance.Name, userType))
|
||||
// postLog.Debug(fmt.Sprintf("[GetInstanceInfoHandler] Retrieved info for instance %d (name: %s), userType: %s", instanceID, instance.Name, userType))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user