diff --git a/source/telemetry2_0.c b/source/telemetry2_0.c index 9acd53ee..ab5a834f 100644 --- a/source/telemetry2_0.c +++ b/source/telemetry2_0.c @@ -109,6 +109,10 @@ T2ERROR initTelemetry() static void terminate() { + struct timespec t2, t_start; + clock_gettime(CLOCK_MONOTONIC, &t_start); + T2Info("=== [SHUTDOWN] telemetry2_0 shutdown started ===\n"); + if(remove("/tmp/.t2ReadyToReceiveEvents") != 0) { printf("removing the file /tmp/.t2ReadyToReceiveEvents failed!\n"); @@ -131,6 +135,9 @@ static void terminate() ReportProfiles_uninit(); http_pool_cleanup(); } + clock_gettime(CLOCK_MONOTONIC, &t2); + T2Info("=== [SHUTDOWN] telemetry2_0 shutdown complete, total=%lldms ===\n", + (long long)(t2.tv_sec - t_start.tv_sec) * 1000 + (t2.tv_nsec - t_start.tv_nsec) / 1000000LL); } static void _print_stack_backtrace(void) diff --git a/telemetry2_0.service b/telemetry2_0.service index fe4d6a87..1870ab10 100644 --- a/telemetry2_0.service +++ b/telemetry2_0.service @@ -24,8 +24,8 @@ Requires=network-online.target [Service] Type=forking ExecStart=/usr/bin/telemetry2_0 -ExecStop=/usr/bin/killall telemetry2_0 -ExecStopPost=/bin/rm -rf /tmp/.t2ReadyToReceiveEvents /tmp/telemetry_initialized_bootup /tmp/.t2ConfigReady +ExecStop=/bin/sh -c 'echo "[SHUTDOWN] $(date +%%Y-%%m-%%dT%%H:%%M:%%S) telemetry2_0 stop initiated by systemd" >> /opt/logs/telemetry2_0.txt.0 2>&1; date +%%s > /tmp/.t2_stop_start 2>/dev/null; /usr/bin/killall telemetry2_0' +ExecStopPost=/bin/sh -c 'echo "[SHUTDOWN] $$(date +%%Y-%%m-%%dT%%H:%%M:%%S) telemetry2_0 stop completed" >> /opt/logs/telemetry2_0.txt.0 2>&1; rm -f /tmp/.t2_stop_start; /bin/rm -rf /tmp/.t2ReadyToReceiveEvents /tmp/telemetry_initialized_bootup /tmp/.t2ConfigReady' Restart=always [Install]