From 497cafbf0f2e96c21539fcc65b149450de262be8 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sat, 15 Aug 2020 18:25:40 -0400 Subject: Add reset interval after which restart interval is reset --- service.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'service.c') diff --git a/service.c b/service.c index 3246fef..fef9b00 100644 --- a/service.c +++ b/service.c @@ -163,8 +163,9 @@ void serviceStart(struct Service *service) { return; } if (service->pid) { - syslog(LOG_NOTICE, "%s[%d] started", service->name, service->pid); service->state = Start; + clock_gettime(CLOCK_MONOTONIC, &service->startTime); + syslog(LOG_NOTICE, "%s[%d] started", service->name, service->pid); return; } @@ -282,7 +283,12 @@ void serviceReap(pid_t pid, int status) { } if (service->intent == Start) { - // TODO: Determine if restart interval should be reset? + struct timespec uptime; + clock_gettime(CLOCK_MONOTONIC, &uptime); + timespecsub(&uptime, &service->startTime, &uptime); + if (timespeccmp(&uptime, &resetInterval, >=)) { + service->restartInterval = restartInterval; + } setDeadline(service); syslog( LOG_NOTICE, "%s[%d] restarting in %lds", -- cgit 1.4.1