From c184cf6ad6f35da222371a9cc47d4446868a9724 Mon Sep 17 00:00:00 2001 From: luwenpeng Date: Thu, 29 Apr 2021 11:06:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=97=AD=20watchdog=20=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=20worker=20thread=20=E7=8A=B6=E6=80=81=E7=9A=84=20deb?= =?UTF-8?q?ug=20=E6=97=A5=E5=BF=97;=20=E5=A2=9E=E5=8A=A0=20usage()=20?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=B8=AE=E5=8A=A9=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/src/proxy.cpp | 23 +++++++++++++++++------ platform/src/watchdog_kni.cpp | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/platform/src/proxy.cpp b/platform/src/proxy.cpp index 23c4cf3..3764b65 100644 --- a/platform/src/proxy.cpp +++ b/platform/src/proxy.cpp @@ -234,7 +234,7 @@ static void __dummy_event_handler(evutil_socket_t fd, short what, void * arg) clock_gettime(CLOCK_MONOTONIC, &now); ATOMIC_SET(&(ctx->lastime), now.tv_sec); - TFE_LOG_DEBUG(g_default_logger, "Worker thread %d Update time %lds", ctx->thread_id, now.tv_sec); + // TFE_LOG_DEBUG(g_default_logger, "Worker thread %d Update time %lds", ctx->thread_id, now.tv_sec); while (ATOMIC_READ(&(ctx->proxy->make_work_thread_sleep)) > 0) { @@ -526,6 +526,17 @@ void tfe_proxy_acceptor_init(struct tfe_proxy * proxy, const char * profile) return; } +static void usage(char *cmd) +{ + fprintf(stderr, "USAGE: %s [OPTIONS]\n", cmd); + fprintf(stderr, " -v -- show version\n"); + fprintf(stderr, " -g -- generate coredump\n"); + fprintf(stderr, " -h -- show help info\n\n"); + fprintf(stderr, "kill -s SIGHUP $pid -- reload zlog configure\n"); + fprintf(stderr, "kill -s SIGUSR1 $pid -- make worker thread sleep\n"); + fprintf(stderr, "kill -s SIGUSR2 $pid -- wake worker thread form sleep\n"); +} + int main(int argc, char * argv[]) { const char * main_profile = "./conf/tfe/tfe.conf"; @@ -536,21 +547,21 @@ int main(int argc, char * argv[]) int opt = 0; bool to_generate_a_segv = false; - while ((opt = getopt(argc, argv, "vg")) != -1) + while ((opt = getopt(argc, argv, "vgh")) != -1) { switch (opt) { case 'v': fprintf(stderr, "Tango Frontend Engine, Version: %s\n", tfe_version()); return 0; - case 'g': fprintf(stderr, "Tango Frontend Engine, prepare to generate a coredump."); to_generate_a_segv = true; break; - - default: - break; + case 'h': /* fall through */ + default: + usage(argv[0]); + return 0; } } diff --git a/platform/src/watchdog_kni.cpp b/platform/src/watchdog_kni.cpp index f0300b6..86d49b6 100644 --- a/platform/src/watchdog_kni.cpp +++ b/platform/src/watchdog_kni.cpp @@ -223,7 +223,7 @@ static void health_check_for_thread_worker(evutil_socket_t fd, short what, void TFE_LOG_ERROR(g_default_logger, "Watchdog thread nowtime %ld, Worker thread %d lastime %ld, Worker thread no reply, Exit ! ! ! ", now.tv_sec, proxy->work_threads[i]->thread_id, temp); exit(-1); } - TFE_LOG_DEBUG(g_default_logger, "Watchdog thread nowtime %ld, Worker thread %d lastime %lds ", now.tv_sec, proxy->work_threads[i]->thread_id, temp); + // TFE_LOG_DEBUG(g_default_logger, "Watchdog thread nowtime %ld, Worker thread %d lastime %lds ", now.tv_sec, proxy->work_threads[i]->thread_id, temp); } }