X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=appimage%2Fctdlvisor.c;h=c9be7e13989fa19700af9fed98d242b0fe7690c5;hb=10d2ab3c4d60fbf991967646cc821b8bb38770b0;hp=d08b63607381c1d90bf53829629cec54f02395ee;hpb=a69148ba680b403a3f07310e037210de606c4a51;p=citadel.git diff --git a/appimage/ctdlvisor.c b/appimage/ctdlvisor.c index d08b63607..c9be7e139 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,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,35 +151,18 @@ pid_t start_webcits() { exit(errno); } else { + fprintf(stderr, "ctdlvisor: webcit (HTTPS) running on pid=%d\n", pid); return(pid); } } -void test_binary_compatibility(void) { - char cmd[1024]; - int ret; - fprintf(stderr, "ctdlvisor: testing compatibility...\n"); - sprintf(cmd, "%s/usr/local/citadel/citserver -c", getenv("APPDIR")); - ret = system(cmd); - if (ret) { - fprintf(stderr, "ctdlvisor: this appimage cannot run on your system.\n" - " The reason may be indicated by any error messages appearing above.\n"); - } - else { - fprintf(stderr, "ctdlvisor: this appimage appears to be compatible with your system.\n"); - } - exit(ret); -} - - void main_loop(void) { int status; pid_t who_exited; 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));