davmac314 / dinit

Service monitoring / "init" system
Apache License 2.0
615 stars 49 forks source link

restart only when exit unexpected #271

Closed lfxx closed 3 months ago

lfxx commented 10 months ago

Can Dinit implement a functionality similar to Supervisor's automatic restart on abnormal exit? Specifically, 1.when the program exits with a status code not present in the exitcode list, it should be considered an abnormal exit, triggering an automatic restart. 2.If the program exits normally with a status code within the exitcode list, no automatic restart is needed. Currently, Dinit automatically restarts in all situations, which is not very convenient.

davmac314 commented 10 months ago

What is your exact use case (i.e. why do you actually need this)? Normally feature requests aren't accepted without a patch (see the README)

lfxx commented 10 months ago

What is your exact use case (i.e. why do you actually need this)? Normally feature requests aren't accepted without a patch (see the README)

Thanks for replying.I have a program that has some bugs, and it occasionally crashes during execution. I use dinit to restart it and continue running when this happens. However, after the program runs successfully, I don't want it to be restarted continuously. I used to achieve this functionality with supervisor, but I couldn't find a way to do it in dinit.

lfxx commented 10 months ago

Dinit has almost all the functionalities of supervisor and is very convenient to use. I have fully transitioned to using dinit in our production environment, and I prefer not to go back to supervisor. It would be great if the functionality I mentioned earlier could be implemented in dinit.

davmac314 commented 10 months ago

I won't be prioritising this, but it'd be easy enough to do (with a new service option). We can leave the issue open and maybe someone will pick it up.

lfxx commented 10 months ago

I won't be prioritising this, but it'd be easy enough to do (with a new service option). We can leave the issue open and maybe someone will pick it up.

Ok.Could you please tag this issue? It would increase the likelihood of someone picking up this issue. Thank you.

davmac314 commented 10 months ago

@mobin-2008 feel free to adjust the labels if you think it's needed

mobin-2008 commented 5 months ago

I'm trying to implement a solution, My plan is to have a specific restart parameter as below:

...
restart = on-failure

this option checks for exit code of program and if it is something >0, Dinit won't restart that process. @lfxx Is it good enough for your usage?

lfxx commented 5 months ago

I'm trying to implement a solution, My plan is to have a specific restart parameter as below:

...
restart = on-failure

this option checks for exit code of program and if it is something >0, Dinit won't restart that process. @lfxx Is it good enough for your usage?

Yes,it is enough.Thank you!