From 755c7efacf7f0359d406afb66dec618fba311b76 Mon Sep 17 00:00:00 2001 From: luwenpeng Date: Thu, 4 Nov 2021 18:04:44 +0300 Subject: [PATCH] =?UTF-8?q?TSG-8331=20=E5=AE=8C=E5=96=84TFE=E7=9A=84Watchd?= =?UTF-8?q?og=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/src/watchdog_tfe.cpp | 11 +++++++++-- script/service/tfe.service | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/platform/src/watchdog_tfe.cpp b/platform/src/watchdog_tfe.cpp index 9cbbee6..a1768e5 100644 --- a/platform/src/watchdog_tfe.cpp +++ b/platform/src/watchdog_tfe.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -52,6 +53,7 @@ static void watchdog_tfe_thread_handle(evutil_socket_t fd, short what, void *arg struct watchdog_tfe *__ctx = proxy->watchdog_tfe; struct timespec now; time_t temp; + const char *check_result = "WATCHDOG=1"; clock_gettime(CLOCK_MONOTONIC, &now); @@ -80,13 +82,18 @@ static void watchdog_tfe_thread_handle(evutil_socket_t fd, short what, void *arg now.tv_sec, proxy->work_threads[i]->thread_id, proxy->work_threads[i]->readable_tid, temp, __ctx->cur_time_window_fail_cnt); if (__ctx->cur_time_window_fail_cnt >= __ctx->timeout_cnt_as_fail) { - TFE_LOG_ERROR(__ctx->logger, "Frome %ld to %ld, there are %d timeouts of the worker threads, Exit !!!", + TFE_LOG_ERROR(__ctx->logger, "Frome %ld to %ld, there are %d timeouts of the worker threads, Ready to Exit !!!", __ctx->cur_time_window_begin, __ctx->cur_time_window_end, __ctx->cur_time_window_fail_cnt); - exit(-1); + check_result = "WATCHDOG=trigger"; } } } } + + if (sd_watchdog_enabled(0, NULL)) + { + sd_notify(0, check_result); + } } struct watchdog_tfe *watchdog_tfe_create(struct tfe_proxy *proxy, const char *profile, void *logger) diff --git a/script/service/tfe.service b/script/service/tfe.service index ec19e52..0f02cb7 100644 --- a/script/service/tfe.service +++ b/script/service/tfe.service @@ -17,6 +17,7 @@ LimitCORE=infinity TasksMax=infinity Delegate=yes KillMode=process +WatchdogSec=10s [Install] WantedBy=multi-user.target