Removed the comments about RMS being an asshole communist. I don't want anyone to...
[citadel.git] / appimage / ctdlvisor.c
index d08b63607381c1d90bf53829629cec54f02395ee..ce6d8a6ec378fb563143647ceef6a45b0c22eafa 100644 (file)
@@ -1,4 +1,3 @@
-//
 // This is a supervisor program that handles start/stop/restart of
 // the various Citadel System components, when we are running on
 // an AppImage instance.
@@ -8,7 +7,7 @@
 // This program is open source software.  It runs great on the
 // Linux operating system (and probably elsewhere).  You can use,
 // copy, and run it under the terms of the GNU General Public
-// License version 3.  Richard Stallman is an asshole communist.
+// License version 3.
 //
 // This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -71,9 +70,18 @@ void signal_handler(int signal) {
                else {
                        what_exited = "unknown";
                }
-               fprintf(stderr, "ctdlvisor: pid=%d (%s) exited, status=%d, exitcode=%d\n", who_exited, what_exited, status, WEXITSTATUS(status));
+               if (who_exited >= 0) {
+                       if (WIFEXITED(status)) {
+                               fprintf(stderr, "ctdlvisor: %d (%s) exited, exitcode=%d\n", who_exited, what_exited, WEXITSTATUS(status));
+                       }
+                       else if (WIFSIGNALED(status)) {
+                               fprintf(stderr, "ctdlvisor: %d (%s) crashed, signal=%d\n", who_exited, what_exited, WTERMSIG(status));
+                       }
+                       else {
+                               fprintf(stderr, "ctdlvisor: %d (%s) ended, status=%d\n", who_exited, what_exited, status);
+                       }
+               }
        } while (who_exited >= 0);
-
        ctdlvisor_exit(0);
 }
 
@@ -99,12 +107,13 @@ pid_t start_citadel() {
        sprintf(bin, "%s/usr/local/citadel/citserver", getenv("APPDIR"));
        pid_t pid = fork();
        if (pid == 0) {
-               fprintf(stderr, "ctdlvisor: executing %s\n", bin);
+               fprintf(stderr, "ctdlvisor: executing %s with data directory %s\n", bin, getenv("CTDL_DIR"));
                detach_from_tty();
                execlp(bin, "citserver", "-x9", "-h", getenv("CTDL_DIR"), NULL);
                exit(errno);
        }
        else {
+               fprintf(stderr, "ctdlvisor: citserver running on pid=%d\n", pid);
                return(pid);
        }
 }
@@ -123,6 +132,7 @@ pid_t start_webcit() {
                exit(errno);
        }
        else {
+               fprintf(stderr, "ctdlvisor: webcit (HTTP) running on pid=%d\n", pid);
                return(pid);
        }
 }
@@ -141,6 +151,7 @@ pid_t start_webcits() {
                exit(errno);
        }
        else {
+               fprintf(stderr, "ctdlvisor: webcit (HTTPS) running on pid=%d\n", pid);
                return(pid);
        }
 }
@@ -169,7 +180,6 @@ void main_loop(void) {
        int citserver_exit_code = 0;
 
        do {
-               fprintf(stderr, "ctdlvisor: waiting for any child process to exit...\n");
                who_exited = waitpid(-1, &status, 0);
                fprintf(stderr, "ctdlvisor: pid=%d exited, status=%d, exitcode=%d\n", who_exited, status, WEXITSTATUS(status));