diff options
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -1,7 +1,15 @@ #include "web.h" +#include <signal.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> + +static volatile sig_atomic_t shutdown_requested = 0; + +static void signal_shutdown(int sig) { + shutdown_requested = 1; +} int main(int argc, char ** argv) { if (argc != 2) { @@ -17,15 +25,27 @@ int main(int argc, char ** argv) { return 1; } + const char *local = getenv("SQLITE_PATH"); + if(local == NULL) { + local = "/var/lib/borgflag/data.db"; + } + struct App app = { - .dbname = "borgflag.db" + .dbname = local, }; struct Server server; server.app = &app; + signal(SIGTERM, signal_shutdown); + signal(SIGINT, signal_shutdown); + prepare_database(&app); web_begin(&server, atoi(argv[1]), admin_user, admin_pass); - getchar(); + + while (!shutdown_requested) { + pause(); + } + web_join(&server); } |
