diff options
-rw-r--r-- | main.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -12,6 +12,7 @@ #include <sys/signalfd.h> #include <sys/eventfd.h> #include <signal.h> +#include <systemd/sd-daemon.h> #include "main.h" #include "uring.h" @@ -198,9 +199,11 @@ signalfd_read(struct cfg *cfg, struct uring_task *task, int res) if (sev->buf < 1000) { fprintf(stderr, "Got a signal to quit\n"); + sd_notifyf(0, "STOPPING=1\nSTATUS=Received signal, exiting"); exit(EXIT_SUCCESS); } else { fprintf(stderr, "Got a signal to dump tree\n"); + sd_notifyf(0, "STOPPING=1\nSTATUS=Received signal, exiting"); dump_tree(cfg); uring_task_put(cfg, &sev->task); announce_delete(cfg); @@ -301,6 +304,8 @@ int main(int argc, char **argv) { struct cfg *cfg; + struct server *server; + unsigned server_count; cfg = cfg_init(argc, argv); @@ -320,6 +325,19 @@ main(int argc, char **argv) uring_task_put(cfg, &cfg->task); + server_count = 0; + list_for_each_entry(server, &cfg->servers, list) + server_count++; + + sd_notifyf(0, "READY=1\n" + "STATUS=Running, %u server configurations loaded\n" + "MAINPID=%lu", + server_count, + (unsigned long)getpid()); + + fprintf(stderr, "%s: started, %u server configurations loaded\n", + argv[0], server_count); + uring_event_loop(cfg); fprintf(stderr, "Event loop exited\n"); |