From 9836d6d22ac22fe7be584da2006ae8d9479096cc Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 19 Aug 2012 15:40:11 -0400 Subject: Add support for socket activation via systemd This prevents the need for starting fcgiwrap explicitly, or using a tool such as spawn-fcgi. The type of socket does not matter, we merely accept a single FD passed from pid 1 and listen on it. --- fcgiwrap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'fcgiwrap.c') diff --git a/fcgiwrap.c b/fcgiwrap.c index 9d87034..2ff33f3 100644 --- a/fcgiwrap.c +++ b/fcgiwrap.c @@ -47,6 +47,10 @@ #include #include +#ifdef HAVE_SYSTEMD +#include +#endif + /* glibc doesn't seem to export it */ #ifndef UNIX_PATH_MAX #define UNIX_PATH_MAX 108 @@ -788,6 +792,14 @@ int main(int argc, char **argv) } } +#ifdef HAVE_SYSTEMD + if (sd_listen_fds(true) > 0) { + /* systemd woke us up. we should never see more than one FD passed to us. */ + if (listen_on_fd(SD_LISTEN_FDS_START) < 0) { + return 1; + } + } else +#endif if (socket_url) { if (setup_socket(socket_url) < 0) { return 1; -- cgit v1.2.3