Systemd notify support
This commit is contained in:
parent
ce68c446d1
commit
143b68588a
|
@ -19,7 +19,7 @@ option(LINK_SUPPORT "Allow hub linking" OFF)
|
||||||
option(SSL_SUPPORT "Enable SSL support" ON)
|
option(SSL_SUPPORT "Enable SSL support" ON)
|
||||||
option(USE_OPENSSL "Use OpenSSL's SSL support" ON )
|
option(USE_OPENSSL "Use OpenSSL's SSL support" ON )
|
||||||
option(SQLITE_SUPPORT "Enable SQLite support" ON)
|
option(SQLITE_SUPPORT "Enable SQLite support" ON)
|
||||||
option(SYSTEMD_SUPPORT "Enable logging to the systemd journal" OFF)
|
option(SYSTEMD_SUPPORT "Enable systemd notify and journal logging" OFF)
|
||||||
option(ADC_STRESS "Enable the stress tester client" OFF)
|
option(ADC_STRESS "Enable the stress tester client" OFF)
|
||||||
|
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
|
@ -37,7 +37,8 @@ endif()
|
||||||
|
|
||||||
if (SYSTEMD_SUPPORT)
|
if (SYSTEMD_SUPPORT)
|
||||||
INCLUDE(FindPkgConfig)
|
INCLUDE(FindPkgConfig)
|
||||||
pkg_search_module(JOURNAL REQUIRED libsystemd-journal)
|
pkg_search_module(SD_DAEMON REQUIRED libsystemd-daemon)
|
||||||
|
pkg_search_module(SD_JOURNAL REQUIRED libsystemd-journal)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
|
@ -182,11 +183,14 @@ if(SSL_SUPPORT)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (SYSTEMD_SUPPORT)
|
if (SYSTEMD_SUPPORT)
|
||||||
target_link_libraries(uhub ${JOURNAL_LIBRARIES})
|
target_link_libraries(uhub ${SD_DAEMON_LIBRARIES})
|
||||||
target_link_libraries(test ${JOURNAL_LIBRARIES})
|
target_link_libraries(uhub ${SD_JOURNAL_LIBRARIES})
|
||||||
target_link_libraries(uhub-passwd ${JOURNAL_LIBRARIES})
|
target_link_libraries(test ${SD_DAEMON_LIBRARIES})
|
||||||
target_link_libraries(uhub-admin ${JOURNAL_LIBRARIES})
|
target_link_libraries(test ${SD_JOURNAL_LIBRARIES})
|
||||||
include_directories(${JOURNAL_INCLUDE_DIRS})
|
target_link_libraries(uhub-passwd ${SD_JOURNAL_LIBRARIES})
|
||||||
|
target_link_libraries(uhub-admin ${SD_JOURNAL_LIBRARIES})
|
||||||
|
include_directories(${SD_DAEMON_INCLUDE_DIRS})
|
||||||
|
include_directories(${SD_JOURNAL_INCLUDE_DIRS})
|
||||||
add_definitions(-DSYSTEMD)
|
add_definitions(-DSYSTEMD)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
#include "uhub.h"
|
#include "uhub.h"
|
||||||
|
|
||||||
|
#ifdef SYSTEMD
|
||||||
|
#include <systemd/sd-daemon.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static int arg_verbose = 5;
|
static int arg_verbose = 5;
|
||||||
static int arg_fork = 0;
|
static int arg_fork = 0;
|
||||||
static int arg_check_config = 0;
|
static int arg_check_config = 0;
|
||||||
|
@ -145,7 +149,16 @@ int main_loop()
|
||||||
}
|
}
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
setup_signal_handlers(hub);
|
setup_signal_handlers(hub);
|
||||||
#endif
|
#ifdef SYSTEMD
|
||||||
|
/* Notify the service manager that this daemon has
|
||||||
|
* been successfully initalized and shall enter the
|
||||||
|
* main loop.
|
||||||
|
*/
|
||||||
|
sd_notifyf(0, "READY=1\n"
|
||||||
|
"MAINPID=%lu", (unsigned long) getpid());
|
||||||
|
#endif /* SYSTEMD */
|
||||||
|
|
||||||
|
#endif /* ! WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
hub_set_variables(hub, &acl);
|
hub_set_variables(hub, &acl);
|
||||||
|
|
Loading…
Reference in New Issue