* New HALT command shuts down server but suspends instead of exiting.
[citadel.git] / citadel / citserver.c
index 411773d08cf3971e99e9c7b7e442fc8a8a527189..dca5ce0ea02c5e1faf77b00db0ed774b2b67aed4 100644 (file)
@@ -185,6 +185,15 @@ void master_cleanup(int exitcode) {
        dump_heap();
 #endif
 
+       /* If the operator requested a halt but not an exit, halt here. */
+       if (shutdown_and_halt) {
+               lprintf(CTDL_NOTICE, "citserver: Halting server without exiting.\n");
+               fflush(stdout); fflush(stderr);
+               while(1) {
+                       sleep(32767);
+               }
+       }
+
        /* Now go away. */
        lprintf(CTDL_NOTICE, "citserver: Exiting with status %d\n", exitcode);
        fflush(stdout); fflush(stderr);
@@ -765,6 +774,18 @@ void cmd_down(void) {
        time_to_die = 1;
 }
 
+/*
+ * Halt the server without exiting the server process.
+ */
+void cmd_halt(void) {
+
+       if (CtdlAccessCheck(ac_aide)) return;
+
+       cprintf("%d Halting server.  Goodbye.\n", CIT_OK);
+       time_to_die = 1;
+       shutdown_and_halt = 1;
+}
+
 /*
  * Schedule or cancel a server shutdown
  */
@@ -1234,6 +1255,10 @@ void do_command_loop(void) {
                cmd_down();
        }
 
+       else if (!strncasecmp(cmdbuf,"HALT",4)) {
+               cmd_halt();
+       }
+
        else if (!strncasecmp(cmdbuf,"SCDN",4)) {
                cmd_scdn(&cmdbuf[5]);
        }