mirror of https://github.com/oxen-io/lokinet
add systemd watchdog if enabled on compile time
This commit is contained in:
parent
8ceb20452a
commit
2eabe98d9b
|
@ -30,6 +30,7 @@ option(WARNINGS_AS_ERRORS "treat all warnings as errors. turn off for developmen
|
|||
option(TRACY_ROOT "include tracy profiler source" OFF)
|
||||
option(VENDOR_LIBSODIUM "use vendored libsodium" OFF)
|
||||
option(WITH_TESTS "build unit tests" ON)
|
||||
option(WITH_SYSTEMD "enable systemd integration for sd_notify" OFF)
|
||||
|
||||
include(cmake/target_link_libraries_system.cmake)
|
||||
include(cmake/add_import_library.cmake)
|
||||
|
@ -46,8 +47,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
|||
include(MacroEnsureOutOfSourceBuild)
|
||||
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out-of-source build. Create a build directory and run 'cmake ${CMAKE_SOURCE_DIR} [options]'.")
|
||||
|
||||
|
||||
|
||||
include(cmake/basic_definitions.cmake)
|
||||
|
||||
if(MSVC_VERSION)
|
||||
|
@ -228,6 +227,15 @@ if(JEMALLOC)
|
|||
set(MALLOC_LIB jemalloc)
|
||||
endif(JEMALLOC)
|
||||
|
||||
|
||||
if(WITH_SYSTEMD)
|
||||
pkg_check_modules(SD REQUIRED libsystemd)
|
||||
add_definitions(-DWITH_SYSTEMD)
|
||||
include_directories(${SD_INCLUDE_DIRS})
|
||||
set(SD_LIBS ${SD_LDFLAGS})
|
||||
endif()
|
||||
|
||||
|
||||
set(ABSEIL_DIR vendor/abseil-cpp)
|
||||
include_directories(SYSTEM ${ABSEIL_DIR})
|
||||
add_subdirectory(vendor/cxxopts)
|
||||
|
@ -248,7 +256,7 @@ if(ANDROID)
|
|||
set(ANDROID_PLATFORM_SRC android/ifaddrs.c)
|
||||
endif(ANDROID)
|
||||
|
||||
set(LIBS ${MALLOC_LIB} ${FS_LIB} ${LIBUV_LIBRARY})
|
||||
set(LIBS ${MALLOC_LIB} ${FS_LIB} ${LIBUV_LIBRARY} ${SD_LIBS})
|
||||
if(TRACY_ROOT)
|
||||
list(APPEND LIBS -ldl)
|
||||
endif()
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#if defined(ANDROID) || defined(IOS)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if defined(WITH_SYSTEMD)
|
||||
#include <systemd/sd-daemon.h>
|
||||
#endif
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
@ -660,6 +663,10 @@ namespace llarp
|
|||
// LogDebug("tick router");
|
||||
const auto now = Now();
|
||||
|
||||
#if defined(WITH_SYSTEMD)
|
||||
::sd_notify(0, "WATCHDOG=1");
|
||||
#endif
|
||||
|
||||
routerProfiling().Tick();
|
||||
|
||||
if(ShouldReportStats(now))
|
||||
|
@ -1029,6 +1036,9 @@ namespace llarp
|
|||
ScheduleTicker(1000);
|
||||
_running.store(true);
|
||||
_startedAt = Now();
|
||||
#if defined(WITH_SYSTEMD)
|
||||
::sd_notify(0, "READY=1");
|
||||
#endif
|
||||
return _running;
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,9 @@ namespace llarp
|
|||
void
|
||||
TryAccess(F visit) const LOCKS_EXCLUDED(_access)
|
||||
{
|
||||
#if defined(LOKINET_DEBUG)
|
||||
NullLock lock(&_access);
|
||||
#endif
|
||||
visit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue