pid_t pid = fork();
if (pid == 0) {
fprintf(stderr, "ctdlvisor: executing citserver\n");
- //detach_from_tty();
+ detach_from_tty();
execlp("/usr/local/citadel/citserver", "citserver", "-x9", "-h", CTDL_DIR, NULL);
exit(errno);
}
pid_t pid = fork();
if (pid == 0) {
fprintf(stderr, "ctdlvisor: executing webcit (http)\n");
- //detach_from_tty();
+ detach_from_tty();
execlp("/usr/local/webcit/webcit", "webcit", "-x9", "-p", "80", "uds", CTDL_DIR, NULL);
exit(errno);
}
pid_t pid = fork();
if (pid == 0) {
fprintf(stderr, "ctdlvisor: executing webcit (https)\n");
- //detach_from_tty();
+ detach_from_tty();
execlp("/usr/local/webcit/webcit", "webcit", "-x9", "-s", "-p", "443", "uds", CTDL_DIR, NULL);
exit(errno);
}
who_exited = waitpid(-1, &status, 0);
fprintf(stderr, "ctdlvisor: pid=%d exited, status=%d, exitcode=%d\n", who_exited, status, WEXITSTATUS(status));
- // A *deliberate* exit of citserver will cause ctdlvisor to shut the whole AppImage down.
+ // A *deliberate* exit of citserver will cause ctdlvisor to shut the whole container down.
// If it crashes, however, we will start it back up.
if (who_exited == citserver_pid) {
citserver_exit_code = WEXITSTATUS(status);
if ((WIFEXITED(status)) && (citserver_exit_code == 0)) {
- fprintf(stderr, "ctdlvisor: citserver exited normally - ending AppImage session\n");
+ fprintf(stderr, "ctdlvisor: citserver exited normally - ending container session\n");
shutting_down = 1;
kill(webcit_pid, SIGTERM);
kill(webcits_pid, SIGTERM);
}
else if ((WIFEXITED(status)) && (citserver_exit_code >= 101) && (citserver_exit_code <= 109)) {
- fprintf(stderr, "ctdlvisor: citserver exited intentionally - ending AppImage session\n");
+ fprintf(stderr, "ctdlvisor: citserver exited intentionally - ending container session\n");
shutting_down = 1;
kill(webcit_pid, SIGTERM);
kill(webcits_pid, SIGTERM);
}
-void install_client_link(void) { // FIXME this is all furkokt and needs to be rethought now that it's docker and not appimage
-
- FILE *fp;
- char path_to_link[PATH_MAX];
- snprintf(path_to_link, sizeof path_to_link, CTDL_DIR "citadel");
- fp = fopen(path_to_link, "w");
- if (!fp) {
- fprintf(stderr, "%s\n", strerror(errno));
- return;
- }
-
- fprintf(fp, "#!/bin/bash\n"
- "export APPDIR=%s\n"
- "export LD_LIBRARY_PATH=${APPDIR}/usr/bin:$LD_LIBRARY_PATH\n"
- "export PATH=${APPDIR}/usr/bin:$PATH\n"
- "exec citadel\n"
- ,
- getenv("APPDIR")
- );
-
- fchmod(fileno(fp), 0755);
- fclose(fp);
-}
-
-
int main(int argc, char **argv) {
int a;
int migrate_mode = 0;
webcit_pid = start_webcit(); // start WebCit HTTP
webcits_pid = start_webcits(); // start WebCit HTTPS
- install_client_link();
-
main_loop();
}