From 34471d85fca14a5ec359d2d06a8d7018cb23beb2 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Wed, 5 Oct 2022 10:23:44 +0200 Subject: systemd: add support for socket activation via systemd (#401) dlt-daemon now support activation via systemd socket. This allows dlt-daemon to be started as soon as an application is requesting access to the dlt socket. This commits implements opening the socket only when UNIX_SOCKET is used for IPC Signed-off-by: Alexander Mohr Signed-off-by: Alexander Mohr --- CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 49494af..2bcad1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,7 @@ option(BUILD_SHARED_LIBS "Set to OFF to build static libraries" option(WITH_SYSTEMD "Set to ON to create unit files and systemd check on dlt-daemon startup" OFF) option(WITH_SYSTEMD_WATCHDOG "Set to ON to use the systemd watchdog in dlt-daemon" OFF) option(WITH_SYSTEMD_JOURNAL "Set to ON to use the systemd journal in dlt-system" OFF) +option(WITH_SYSTEMD_SOCKET_ACTIVATION "Set to ON to use systemd socket activation" OFF) option(WITH_DOC "Set to ON to build documentation target" OFF) option(WITH_MAN "Set to ON to build man pages" OFF) option(WITH_CHECK_CONFIG_FILE "Set to ON to create a configure file of CheckIncludeFiles and CheckFunctionExists" OFF) @@ -92,6 +93,7 @@ option(WITH_EXTENDED_FILTERING "Set to OFF to build without extended filtering. option(WITH_DLT_DAEMON_VSOCK_IPC "Set to ON to enable VSOCK support in daemon" OFF) option(WITH_DLT_LIB_VSOCK_IPC "Set to ON to enable VSOCK support in library (DLT_IPC is not used in library)" OFF) + set(DLT_VSOCK_PORT "13490" CACHE STRING "VSOCK port number for logging traffic.") # RPM settings @@ -214,7 +216,7 @@ else() message(STATUS "Disable network trace interface since message queue is not supported") endif() -if(WITH_SYSTEMD OR WITH_SYSTEMD_WATCHDOG OR WITH_SYSTEMD_JOURNAL) +if(WITH_SYSTEMD OR WITH_SYSTEMD_WATCHDOG OR WITH_SYSTEMD_JOURNAL OR WITH_SYSTEMD_SOCKET_ACTIVATION) find_package(PkgConfig REQUIRED) execute_process(COMMAND pkg-config --modversion systemd OUTPUT_VARIABLE SYSTEMD_VERSION) string(REPLACE "\n" "" SYSTEMD_VERSION ${SYSTEMD_VERSION}) @@ -231,6 +233,13 @@ if(WITH_SYSTEMD OR WITH_SYSTEMD_WATCHDOG OR WITH_SYSTEMD_JOURNAL) add_definitions(-DDLT_SYSTEMD_JOURNAL_ENABLE) endif() + if (WITH_SYSTEMD_SOCKET_ACTIVATION) + if(NOT DLT_IPC STREQUAL "UNIX_SOCKET") + message(FATAL_ERROR "WITH_SYSTEMD_SOCKET_ACTIVATION is only supported for UNIX_SOCKET") + endif() + add_definitions(-DDLT_SYSTEM_SOCKET_ACTIVATION_ENABLE) + endif() + set(systemd_SRCS ${PROJECT_SOURCE_DIR}/systemd/3rdparty/sd-daemon.c) set(SYSTEMD_UNITDIR "${CMAKE_INSTALL_PREFIX}/lib/systemd/system" CACHE PATH -- cgit v1.2.1