Page MenuHomeFreeBSD

daemon: Add -C (--restart-count) option
ClosedPublic

Authored by otis on Apr 25 2024, 1:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 6, 3:34 PM
Unknown Object (File)
Fri, Nov 1, 3:00 AM
Unknown Object (File)
Fri, Nov 1, 3:00 AM
Unknown Object (File)
Fri, Nov 1, 3:00 AM
Unknown Object (File)
Fri, Nov 1, 3:00 AM
Unknown Object (File)
Fri, Nov 1, 2:59 AM
Unknown Object (File)
Fri, Nov 1, 2:36 AM
Unknown Object (File)
Oct 17 2024, 11:15 AM

Details

Summary

Add a new option (-C, --restart-count) to specify the maximum
number of times that the controlled process is restarted if
restart (-r) is restarted.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 57413
Build 54301: arc lint + arc unit

Event Timeline

otis requested review of this revision.Apr 25 2024, 1:43 PM
otis created this revision.

And while here, also mandoc -Tlint a bit.

lgtm, whats this addressing? Whats the system behaviour when the count limit is hit?

lgtm, whats this addressing? Whats the system behaviour when the count limit is hit?

it is addressing a case when you only want the process supervised to be restarted only certain amount of times (and then not restarted at all). it is a complementary switch to -r (--restart). when the limit is hit, daemon(8) will terminate as usual.

you can then, for example, monitor the processes more easily (like, check for daemon(8) as well as for the supervised proces).

0mp added inline comments.
usr.sbin/daemon/daemon.8
73

-C should go before -c.

77

The maximum number of restarts should be documented as well.

81

The final period can be written at the end of this line:

.Fl -restart .

Address comments from 0mp

otis marked 3 inline comments as done.Apr 25 2024, 2:48 PM
usr.sbin/daemon/daemon.c
60

I think I'm missing someting in the design; why the arbitrary limit here? It seems reasonable, but it's not clear to me that we really care if someone wants to say restart it 512 times then call it good.

349

I'm not sure that it makes sense to have this mode when -C 0 is used -- if they requested restart, then it feels a little weird to have a knob to immediately disable that indirectly. I don't think I strongly object, though.

otis marked 2 inline comments as done.Apr 25 2024, 6:21 PM
otis added inline comments.
usr.sbin/daemon/daemon.c
60

I think I'm missing someting in the design; why the arbitrary limit here? It seems reasonable, but it's not clear to me that we really care if someone wants to say restart it 512 times then call it good.

there has to be some limit. 512 seemed too much, 32 too less. 128 seemed reasonable to me. anyway, I don't insist on this value, perhaps as little as 16 or 32 would also do.

349

I'm not sure that it makes sense to have this mode when -C 0 is used -- if they requested restart, then it feels a little weird to have a knob to immediately disable that indirectly. I don't think I strongly object, though.

if you call this from a script, let's say, you only need to parametrize one value (the value for -C) while keeping the rest of the command unmodified. that's my imagination of a use case (at least the one I can think of from my experience).

otis marked 2 inline comments as done.

rebase

Can this be either approved od rejected, please? It is now lingering.

This revision is now accepted and ready to land.May 13 2024, 4:36 AM
This revision was automatically updated to reflect the committed changes.