From 9d864e5526d39ef974557c9b406bc3ada03ed4c1 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Tue, 10 Oct 2023 17:16:53 -0400 Subject: Add maximum restart interval --- kitd.8 | 10 +++++++++- kitd.c | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/kitd.8 b/kitd.8 index 4bce90b..54a9fa3 100644 --- a/kitd.8 +++ b/kitd.8 @@ -10,6 +10,7 @@ .Nm .Op Fl d .Op Fl c Ar cooloff +.Op Fl m Ar maximum .Op Fl n Ar name .Op Fl t Ar restart .Ar command ... @@ -51,6 +52,13 @@ Do not daemonize. Log to standard error as well as .Xr syslog 3 . +.It Fl m Ar maximum +The maximum interval between restarts. +.Pp +The interval is interpreted as with +.Fl c . +The default maximum interval is +.Sy 1h . .It Fl n Ar name Set the name of the process and the logging prefix. @@ -58,7 +66,7 @@ The default is the last path component of .Ar command . .It Fl t Ar restart -The initial interval between automatic restarts. +The initial interval between restarts. This interval is doubled each time the child process is restarted. diff --git a/kitd.c b/kitd.c index d76cac1..261f9eb 100644 --- a/kitd.c +++ b/kitd.c @@ -107,10 +107,12 @@ int main(int argc, char *argv[]) { const char *name = NULL; struct timeval restart = { .tv_sec = 1 }; struct timeval cooloff = { .tv_sec = 15*M }; - for (int opt; 0 < (opt = getopt(argc, argv, "c:dn:t:"));) { + struct timeval maximum = { .tv_sec = 1*H }; + for (int opt; 0 < (opt = getopt(argc, argv, "c:dm:n:t:"));) { switch (opt) { break; case 'c': parse(&cooloff, optarg); break; case 'd': daemonize = false; + break; case 'm': parse(&maximum, optarg); break; case 'n': name = optarg; break; case 't': parse(&restart, optarg); break; default: return 1; @@ -257,7 +259,11 @@ int main(int argc, char *argv[]) { syslog(LOG_INFO, "restarting in %s", humanize(&interval)); struct itimerval timer = { .it_value = interval }; setitimer(ITIMER_REAL, &timer, NULL); + timeradd(&interval, &interval, &interval); + if (timercmp(&interval, &maximum, >)) { + interval = maximum; + } } if (signals[SIGINFO]) { -- cgit 1.4.1 c?h=2.1p1&id=60f738abfe8b8cc30ab433b92259ce79810cbfbd&follow=1'>ring.c (unfollow)
Commit message (Expand)Author
2019-10-25Clean up server codeJune McEnroe
2019-10-25Clean up listen APIJune McEnroe
2019-10-25Use produce/consume words for ring bufferJune McEnroe
2019-10-25Implement client reading from ring bufferJune McEnroe
2019-10-25Implement ringDiff and ringReadJune McEnroe
2019-10-24Remove manual client naming from manual pageJune McEnroe
2019-10-24Zero entire Client structJune McEnroe
2019-10-24Register readers by client usernamesJune McEnroe
2019-10-24Unset non-blocking on clientsJune McEnroe
2019-10-24Intercept client QUITJune McEnroe
2019-10-24Only set NeedCapEnd if unregisteredJune McEnroe
2019-10-24Set client-side origin to irc.invalidJune McEnroe
2019-10-24Factor out client-side origin nameJune McEnroe
2019-10-24Intercept all CAP commands from clientsJune McEnroe
2019-10-24Ignore further CAP ENDJune McEnroe
2019-10-24Implement client CAP for server-timeJune McEnroe
2019-10-24Implement ringWriteJune McEnroe
2019-10-24Make clientFormat publicJune McEnroe
2019-10-24Make serverFormat publicJune McEnroe
2019-10-24Rename some thingsJune McEnroe
2019-10-23Add ISUPPORT draft to STANDARDSJune McEnroe
2019-10-23Track own originJune McEnroe
2019-10-23Track channels and sync ISUPPORTJune McEnroe
2019-10-23Track nick changesJune McEnroe
2019-10-23Rename Command to MessageJune McEnroe
2019-10-23Synchronize state after client registrationJune McEnroe
2019-10-23Send to server if client has no needsJune McEnroe
2019-10-23Implement some amount of client connectionJune McEnroe
2019-10-23Set clients non-blockingJune McEnroe
2019-10-23Clean up state.c and factor out parsingJune McEnroe
2019-10-23Respond to pingsJune McEnroe
2019-10-23Add verbose flagJune McEnroe
2019-10-23Set NOSIGPIPE on server connectionJune McEnroe
2019-10-23Set an initial loop capJune McEnroe
2019-10-23Fix rest parsingJune McEnroe
2019-10-23Add dynamic poll listJune McEnroe
2019-10-23Don't assume commands have targets and handle ERRORJune McEnroe
2019-10-23Clean up state somewhatJune McEnroe
2019-10-23Actually send the buffer...June McEnroe
2019-10-23Add stateJune McEnroe