#include "app.h" #include "web.h" #include #include #include #include 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) { printf("%s PORT\n", argv[0]); return 1; } const char *admin_user = getenv("ADMIN_USER"); const char *admin_pass = getenv("ADMIN_PASS"); if (admin_user == NULL || admin_pass == NULL) { fprintf(stderr, "Error: ADMIN_USER and ADMIN_PASS environment variables must be set\n"); return 1; } const char *local = getenv("SQLITE_PATH"); if(local == NULL) { local = "/var/lib/borgflag/data.db"; } struct App app = { .dbname = local, }; struct Server server; server.app = &app; signal(SIGTERM, signal_shutdown); signal(SIGINT, signal_shutdown); app_startup(&app); web_begin(&server, atoi(argv[1]), admin_user, admin_pass); while (!shutdown_requested) { pause(); } web_join(&server); }