diff options
| author | Qiuwen Lu <[email protected]> | 2017-06-23 14:51:23 +0800 |
|---|---|---|
| committer | Qiuwen Lu <[email protected]> | 2017-06-23 14:51:23 +0800 |
| commit | 9748c7cd41dd4b92a100a2a1b257005da854fdbb (patch) | |
| tree | 414125e3c97423e1d8c00991d2ba55fb6e3048e7 /tunnat | |
| parent | 9bd33aacd9457f42eb4cae4b7e91560936cc75d9 (diff) | |
增加TUNNAT服务配置文件及自动安装脚本。v4.2.1-20170623
Diffstat (limited to 'tunnat')
| -rw-r--r-- | tunnat/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | tunnat/src/core.cc | 14 |
2 files changed, 16 insertions, 3 deletions
diff --git a/tunnat/CMakeLists.txt b/tunnat/CMakeLists.txt index 30829e2..e5719c4 100644 --- a/tunnat/CMakeLists.txt +++ b/tunnat/CMakeLists.txt @@ -10,12 +10,11 @@ add_definitions(${DPDK_C_PREDEFINED}) add_executable(mrtunnat src/core.cc src/runtime.cc src/tunnel.cc src/session.cc src/monit.cc) target_link_libraries(mrtunnat MESA_prof_load_static MESA_htable marsio infra) target_link_libraries(mrtunnat rt pthread dl ${SYSTEMD_LIBRARIES}) -target_include_directories(mrtunnat INTERFACE ${SYSTEMD_INCLUDE_DIRS}) +target_include_directories(mrtunnat PRIVATE ${SYSTEMD_INCLUDE_DIRS}) target_include_directories(mrtunnat PRIVATE include) # Install -#install(TARGETS mrtunnat LIBRARY DESTINATION bin COMPONENT Program) -#install(FILES libpag.h DESTINATION include COMPONENT Program) +install(TARGETS mrtunnat RUNTIME DESTINATION bin COMPONENT Program) # test add_executable(TestSession test/TestSession.cc src/session.cc src/tunnel.cc) diff --git a/tunnat/src/core.cc b/tunnat/src/core.cc index 7454c3a..3b08469 100644 --- a/tunnat/src/core.cc +++ b/tunnat/src/core.cc @@ -8,6 +8,8 @@ extern "C" { +#include <systemd/sd-daemon.h> +#include <unistd.h> #include <getopt.h> #include <common.h> #include <marsio.h> @@ -256,6 +258,13 @@ int tunnat_version() extern void * tunnat_monit_thread(void * arg); +/* 检查本进程是否通过SYSTEMD启动 */ +static int __check_is_notify() +{ + char * notify_socket = getenv("NOTIFY_SOCKET"); + return notify_socket == NULL ? 0 : 1; +} + int main(int argc, char * argv[]) { /* 创建全局运行句柄 */ @@ -314,6 +323,11 @@ int main(int argc, char * argv[]) } } + + /* 采用NOTIFY方式启动,通知操作系统完成了初始化 */ + if (__check_is_notify()) sd_notify(0, "READY=1"); + sleep(1); + for (unsigned int i = 0; i < g_instance->nr_thread; i++) { pthread_join(__pid[i], NULL); |
