enum ctdb_runstate runstate_from_string(const char *label);
void ctdb_set_runstate(struct ctdb_context *ctdb, enum ctdb_runstate runstate);
+void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code);
+
#define CTDB_MONITORING_ACTIVE 0
#define CTDB_MONITORING_DISABLED 1
return 0;
case CTDB_CONTROL_SHUTDOWN:
- DEBUG(DEBUG_NOTICE,("Received SHUTDOWN command. Stopping CTDB daemon.\n"));
- ctdb_set_runstate(ctdb, CTDB_RUNSTATE_SHUTDOWN);
- ctdb_stop_recoverd(ctdb);
- ctdb_stop_keepalive(ctdb);
- ctdb_stop_monitoring(ctdb);
- ctdb_release_all_ips(ctdb);
- ctdb_event_script(ctdb, CTDB_EVENT_SHUTDOWN);
- if (ctdb->methods != NULL) {
- ctdb->methods->shutdown(ctdb);
- }
- exit(0);
+ DEBUG(DEBUG_NOTICE,("Received SHUTDOWN command.\n"));
+ ctdb_shutdown_sequence(ctdb, 0);
case CTDB_CONTROL_TAKEOVER_IPv4:
CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_public_ipv4));
return kill(pid, 0);
}
+
+void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code)
+{
+ DEBUG(DEBUG_NOTICE,("Shutdown sequence commencing.\n"));
+ ctdb_set_runstate(ctdb, CTDB_RUNSTATE_SHUTDOWN);
+ ctdb_stop_recoverd(ctdb);
+ ctdb_stop_keepalive(ctdb);
+ ctdb_stop_monitoring(ctdb);
+ ctdb_release_all_ips(ctdb);
+ ctdb_event_script(ctdb, CTDB_EVENT_SHUTDOWN);
+ if (ctdb->methods != NULL) {
+ ctdb->methods->shutdown(ctdb);
+ }
+
+ DEBUG(DEBUG_NOTICE,("Shutdown sequence complete, exiting.\n"));
+ exit(exit_code);
+}
DEBUG(DEBUG_ALERT,(__location__
"ctdb_recheck_persistent_health() failed (%llu times) - prepare shutdown\n",
(unsigned long long)ctdb->db_persistent_check_errors));
- ctdb_stop_recoverd(ctdb);
- ctdb_stop_keepalive(ctdb);
- ctdb_stop_monitoring(ctdb);
- ctdb_release_all_ips(ctdb);
- if (ctdb->methods != NULL) {
- ctdb->methods->shutdown(ctdb);
- }
- ctdb_event_script(ctdb, CTDB_EVENT_SHUTDOWN);
- DEBUG(DEBUG_ALERT,("ctdb_recheck_persistent_health() failed - Stopping CTDB daemon\n"));
- exit(11);
+ ctdb_shutdown_sequence(ctdb, 11);
}
ctdb->db_persistent_check_errors = 0;