troglobit / finit

Fast init for Linux. Cookies included
https://troglobit.com/projects/finit/
MIT License
632 stars 63 forks source link

Finer control over restarting behaviour? #306

Open hongkongkiwi opened 1 year ago

hongkongkiwi commented 1 year ago

Is it possible to add a couple of variables for me so I can change the restart behaviour when a service crashes? In my case, it's a modem dialer script which just exits when connection drops.

e.g. I want to attempt to restart 20 times at 10 seconds between each try, THEN 30 seconds between each try forever.

I was thinking to solve it maybe we could add two variables: restart_early_tries and restart_early_sec which allows fine tuning of the behaviour (by default I think it's restart_early_tries:5 restart_early_sec:2 according to the docs).

So that way I could specify the following on a service

restart_early_tries:20 restart_early_sec:10 restart_sec:30 restart:always
hongkongkiwi commented 1 year ago

Actually I just realised that this won't really solve my problem because in my case my service actually stays up for a while before the connection drops. So I think I need to change the way it works and have my own backoff strategy.

But I do think this is a great idea to implement, because it will allow the user to specify a bit more control over restarting for some services.

troglobit commented 1 year ago

It's possible, but I really think this is closing up on being its own daemon with monitoring and restart strategies. Possibly shipped with Finit.

hongkongkiwi commented 1 year ago

It would definitely make sense to split this out into a separate daemon, it would probably simplify finit a lot. Are you thinking something like restartd on ubuntu? Like a seperate daemon which handles all process restarting?

Or are you thinking to run a wrapper in front of each process which handles reestarting upon crash ?

troglobit commented 1 year ago

Heh, never even heard of restartd before. Something like that, yes.

Yup, like a little extra helper/crutch.