summary refs log tree commit diff
path: root/service.c
diff options
context:
space:
mode:
Diffstat (limited to 'service.c')
-rw-r--r--service.c10
1 files changed, 8 insertions, 2 deletions
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",