X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=appimage%2Fctdlvisor.c;h=ce6d8a6ec378fb563143647ceef6a45b0c22eafa;hb=fd396aeb6d3e10be928dd899ae228147b1728fb3;hp=4bc4696b027fcd5b642124de290a3fe342a20fc8;hpb=bcf3a77820854f20ce20d8227411e837904099a4;p=citadel.git diff --git a/appimage/ctdlvisor.c b/appimage/ctdlvisor.c index 4bc4696b0..ce6d8a6ec 100644 --- a/appimage/ctdlvisor.c +++ b/appimage/ctdlvisor.c @@ -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,17 +70,18 @@ void signal_handler(int signal) { else { what_exited = "unknown"; } - 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); + 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); } @@ -107,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); } } @@ -131,6 +132,7 @@ pid_t start_webcit() { exit(errno); } else { + fprintf(stderr, "ctdlvisor: webcit (HTTP) running on pid=%d\n", pid); return(pid); } } @@ -149,6 +151,7 @@ pid_t start_webcits() { exit(errno); } else { + fprintf(stderr, "ctdlvisor: webcit (HTTPS) running on pid=%d\n", pid); return(pid); } } @@ -177,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));