summary refs log tree commit diff
path: root/service.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--service.c54
1 files changed, 21 insertions, 33 deletions
diff --git a/service.c b/service.c
index d8998af..23d1de9 100644
--- a/service.c
+++ b/service.c
@@ -114,31 +114,25 @@ err:
 
 void serviceStatus(struct Service *service) {
 	if (service->state == Stop && service->intent == Stop) {
-		syslog(LOG_INFO, "%s is stopped", service->name);
+		syslog(LOG_INFO, "%s[] is stopped", service->name);
 	} else if (service->state == Stop && service->intent == Start) {
 		struct timespec now, timeleft;
 		clock_gettime(CLOCK_MONOTONIC, &now);
 		timespecsub(&service->restartDeadline, &now, &timeleft);
 		syslog(
-			LOG_INFO, "%s is restarting in %jds",
-			service->name, (intmax_t)timeleft.tv_sec
+			LOG_INFO, "%s[] is restarting in %lds",
+			service->name, (long)timeleft.tv_sec
 		);
 	} else if (service->state == Stop && service->intent == Restart) {
-		syslog(LOG_INFO, "%s is restarting", service->name);
+		syslog(LOG_INFO, "%s[] is restarting", service->name);
 	} else if (service->state == Start && service->intent == Start) {
-		syslog(
-			LOG_INFO, "%s[%jd] is started",
-			service->name, (intmax_t)service->pid
-		);
+		syslog(LOG_INFO, "%s[%d] is started", service->name, service->pid);
 	} else if (service->state == Start && service->intent == Stop) {
-		syslog(
-			LOG_INFO, "%s[%jd] is stopping",
-			service->name, (intmax_t)service->pid
-		);
+		syslog(LOG_INFO, "%s[%d] is stopping", service->name, service->pid);
 	} else if (service->state == Start && service->intent == Restart) {
 		syslog(
-			LOG_INFO, "%s[%jd] is stopping for restart",
-			service->name, (intmax_t)service->pid
+			LOG_INFO, "%s[%d] is stopping for restart",
+			service->name, service->pid
 		);
 	}
 }
@@ -169,10 +163,7 @@ void serviceStart(struct Service *service) {
 		return;
 	}
 	if (service->pid) {
-		syslog(
-			LOG_INFO, "%s[%jd] start",
-			service->name, (intmax_t)service->pid
-		);
+		syslog(LOG_INFO, "%s[%d] started", service->name, service->pid);
 		service->state = Start;
 		return;
 	}
@@ -213,8 +204,8 @@ void serviceSignal(struct Service *service, int signal) {
 	int error = kill(service->pid, signal);
 	if (error) {
 		syslog(
-			LOG_ERR, "kill(%s[%jd], %s): %m",
-			service->name, (intmax_t)service->pid, sys_signame[signal]
+			LOG_ERR, "kill(%s[%d], %s): %m",
+			service->name, service->pid, sys_signame[signal]
 		);
 	}
 }
@@ -234,10 +225,7 @@ void serviceRestart(struct Service *service) {
 }
 
 static void serviceLog(struct Service *service, int pri, const char *log) {
-	syslog(
-		pri, "%s[%ju]: %s",
-		service->name, (intmax_t)service->pid, log
-	);
+	syslog(pri, "%s[%d]: %s", service->name, service->pid, log);
 }
 
 void serviceRead(struct Service *service) {
@@ -269,7 +257,7 @@ void serviceReap(pid_t pid, int status) {
 		break;
 	}
 	if (!service) {
-		syslog(LOG_WARNING, "reaping unknown child %jd", (intmax_t)pid);
+		syslog(LOG_WARNING, "reaping unknown child %d", pid);
 		return;
 	}
 	serviceFlush(service);
@@ -282,26 +270,26 @@ void serviceReap(pid_t pid, int status) {
 		}
 		if (exit) {
 			syslog(
-				LOG_WARNING, "%s[%jd] exit %d",
-				service->name, (intmax_t)pid, exit
+				LOG_WARNING, "%s[%d] exited %d",
+				service->name, pid, exit
 			);
 		}
 	} else if (WIFSIGNALED(status)) {
 		syslog(
-			LOG_WARNING, "%s[%jd] signal %s",
-			service->name, (intmax_t)pid, sys_signame[WTERMSIG(status)]
+			LOG_WARNING, "%s[%d] signaled %s",
+			service->name, pid, sys_signame[WTERMSIG(status)]
 		);
 	}
 
 	if (service->intent == Start) {
+		// TODO: Determine if restart interval should be reset?
 		setDeadline(service);
 		syslog(
-			LOG_INFO, "%s[%jd] restart in %jds",
-			service->name, (intmax_t)pid,
-			(intmax_t)service->restartInterval.tv_sec
+			LOG_INFO, "%s[%d] restarting in %lds",
+			service->name, pid, (long)service->restartInterval.tv_sec
 		);
 	} else {
-		syslog(LOG_INFO, "%s[%jd] stop", service->name, (intmax_t)pid);
+		syslog(LOG_INFO, "%s[%d] stopped", service->name, pid);
 	}
 	if (service->intent == Restart) {
 		serviceStart(service);