diff options
author | Christian Hesse <mail@eworm.de> | 2016-12-01 21:35:18 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2016-12-01 21:35:18 +0100 |
commit | b24304ebe9d45044db4798f904d55cc26bca977c (patch) | |
tree | c65dd1f1e3bb4c63be855143c6ddfd8522424c17 | |
parent | d95a2a13593224986628ceff346eed07007c199c (diff) | |
download | pacredir-b24304ebe9d45044db4798f904d55cc26bca977c.tar.gz pacredir-b24304ebe9d45044db4798f904d55cc26bca977c.tar.zst |
Use systemd service manager notification
Notify systemd service manager when our initialization sequence
completed.
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | pacredir.c | 3 | ||||
-rw-r--r-- | pacredir.h | 3 | ||||
-rw-r--r-- | systemd/pacredir.service | 1 |
4 files changed, 8 insertions, 0 deletions
@@ -14,6 +14,7 @@ SED := sed # flags CFLAGS += -std=c11 -O2 -fPIC -Wall -Werror CFLAGS_EXTRA += -lpthread +CFLAGS_EXTRA += $(shell pkg-config --libs --cflags libsystemd) CFLAGS_EXTRA += $(shell pkg-config --libs --cflags libcurl) CFLAGS_EXTRA += $(shell pkg-config --libs --cflags avahi-client) CFLAGS_EXTRA += $(shell pkg-config --libs --cflags libmicrohttpd) @@ -720,6 +720,9 @@ int main(int argc, char ** argv) { signal(SIGKILL, sig_callback); signal(SIGINT, sig_callback); + /* report ready to systemd */ + sd_notifyf(0, "READY=1\nSTATUS=Waiting for requests to redirect...\nMAINPID=%lu", (unsigned long) getpid()); + /* run the main loop */ avahi_simple_poll_loop(simple_poll); @@ -24,6 +24,9 @@ #include <sys/stat.h> #include <time.h> +/* systemd headers */ +#include <systemd/sd-daemon.h> + /* Avahi headers */ #include <avahi-client/lookup.h> #include <avahi-common/error.h> diff --git a/systemd/pacredir.service b/systemd/pacredir.service index c64a5d5..bc5a13f 100644 --- a/systemd/pacredir.service +++ b/systemd/pacredir.service @@ -4,6 +4,7 @@ Requires=avahi-daemon.service After=avahi-daemon.service network.target network-online.target [Service] +Type=notify User=nobody Group=nobody ExecStart=/usr/bin/pacredir |