diff --git a/daemon/main.c b/daemon/main.c index 9075461b1..a518a206c 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -817,6 +817,8 @@ int main(int argc, char **argv) { rtpe_config.num_threads = 4; } + service_notify("READY=1\n"); + for (;idx= 1.0.1), libswresample-dev (>= 6:10), + libsystemd-dev, libxmlrpc-c3-dev (>= 1.16.07) | libxmlrpc-core-c3-dev (>= 1.16.07), markdown, zlib1g-dev, diff --git a/debian/ngcp-rtpengine-daemon.service b/debian/ngcp-rtpengine-daemon.service index f937f65ec..9046376a4 100644 --- a/debian/ngcp-rtpengine-daemon.service +++ b/debian/ngcp-rtpengine-daemon.service @@ -5,7 +5,7 @@ After=remote-fs.target Requires=network-online.target [Service] -Type=simple +Type=notify EnvironmentFile=/etc/default/ngcp-rtpengine-daemon PIDFile=/var/run/ngcp-rtpengine-daemon.pid ExecStartPre=/usr/sbin/ngcp-rtpengine-iptables-setup start diff --git a/debian/ngcp-rtpengine-recording-daemon.service b/debian/ngcp-rtpengine-recording-daemon.service index ee0f9f605..e2e4ed319 100644 --- a/debian/ngcp-rtpengine-recording-daemon.service +++ b/debian/ngcp-rtpengine-recording-daemon.service @@ -7,7 +7,7 @@ Requires=network-online.target Requires=ngcp-rtpengine-recording-nfs-mount.service [Service] -Type=simple +Type=notify PIDFile=/run/ngcp-rtpengine-recording-daemon.pid ExecStart=/usr/sbin/rtpengine-recording -f -E --pidfile /run/ngcp-rtpengine-recording-daemon.pid --config-file /etc/rtpengine/rtpengine-recording.conf diff --git a/lib/auxlib.c b/lib/auxlib.c index 3eecdb206..485dece91 100644 --- a/lib/auxlib.c +++ b/lib/auxlib.c @@ -7,6 +7,9 @@ #include #include #include +#ifdef HAVE_LIBSYSTEMD +#include +#endif #include "log.h" #include "loglib.h" @@ -43,6 +46,12 @@ void wpidfile() { fclose(fp); } +void service_notify(const char *message) { +#ifdef HAVE_LIBSYSTEMD + sd_notify(0, message); +#endif +} + static unsigned int options_length(const GOptionEntry *arr) { unsigned int len = 0; diff --git a/lib/auxlib.h b/lib/auxlib.h index 12dec6efc..395fee1be 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -20,6 +20,7 @@ extern struct rtpengine_common_config *rtpe_common_config_ptr; void daemonize(void); void wpidfile(void); +void service_notify(const char *message); void config_load(int *argc, char ***argv, GOptionEntry *entries, const char *description, char *default_config, char *default_section, struct rtpengine_common_config *); diff --git a/lib/lib.Makefile b/lib/lib.Makefile index 77a9b705d..728a11aeb 100644 --- a/lib/lib.Makefile +++ b/lib/lib.Makefile @@ -25,6 +25,15 @@ ifeq ($(RTPENGINE_VERSION),) endif CFLAGS+= -DRTPENGINE_VERSION="\"$(RTPENGINE_VERSION)\"" +# look for libsystemd +ifeq ($(shell pkg-config --exists libsystemd && echo yes),yes) +have_libsystemd := yes +endif +ifeq ($(have_libsystemd),yes) +CFLAGS+= $(shell pkg-config --cflags libsystemd) +CFLAGS+= -DHAVE_LIBSYSTEMD +LDLIBS+= $(shell pkg-config --libs libsystemd) +endif ifeq ($(DBG),yes) CFLAGS+= -D__DEBUG=1 diff --git a/recording-daemon/main.c b/recording-daemon/main.c index 936e64fc0..0aadf3521 100644 --- a/recording-daemon/main.c +++ b/recording-daemon/main.c @@ -188,11 +188,14 @@ int main(int argc, char **argv) { daemonize(); wpidfile(); + service_notify("READY=1\n"); + for (int i = 0; i < num_threads; i++) start_poller_thread(); wait_for_signal(); + service_notify("STOPPING=1\n"); dbg("shutting down"); wait_threads_finish();