summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2021-11-04 18:04:44 +0300
committerluwenpeng <[email protected]>2021-11-04 18:04:44 +0300
commit755c7efacf7f0359d406afb66dec618fba311b76 (patch)
treea0e654154a66fa6c79e0efe2b34df230ef503390
parentcb15d3340f63f5b0b19f2559ba516f86b5153f0a (diff)
TSG-8331 完善TFE的Watchdog功能v4.5.23-20211105
-rw-r--r--platform/src/watchdog_tfe.cpp11
-rw-r--r--script/service/tfe.service1
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 <assert.h>
#include <sys/prctl.h>
#include <stdlib.h>
+#include <systemd/sd-daemon.h>
#include <proxy.h>
#include <platform.h>
@@ -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