![]() ![]() However systemd is left in a strange position, where they also support Restart=always, and that is what they like to set for the majority of long-running services inside the systemd project. The advantage of Restart=on-failure is that it is less risky for systemd to recommend using it (as the man page does). Sometimes people use a plain kill command, but there are also scripts like apachectl. systemd-networkd uses it for this reason.Īnswer 2: System administration practices may include killing or messaging service processes to stop them. However Restart=on-failure might be used for a service which can exit on idle in some configurations, but not in others. Because an idle timeout implies that the service has already been set up to start automatically when a new request is made. Intriguingly, it would not matter so much if a bug/error causes such a service to exit "successfully", when it should not have done so. In particular, if the service exits after an idle timeout. #MUST RESTART ITSYCAL WITH EVERY RESTART CODE#Why would we ever want check whether the service terminated with exit code 0 ( EXIT_SUCCESS) ? There might even have been a weird bug / error in the service, that caused it to terminate with exit code 0 when it should not have done so.Īnswer 1: There are some units that must not use Restart=always. Easier to implement, easier to understand. A restarted service enters the failed state only after the start limits are suggested there is another way to look at this question. Note that service restart is subject to unit start rate limiting configured with StartLimitIntervalSec= and StartLimitBurst=, see systemd.unit(5) for details. So having Restart=always (or Restart=on-success) allows to use SIGHUP for restarting, even without the service itself supporting that.Īlso, as far as I can read the man page, always doesn't mean it would override the limits set by StartLimitInterval and StartLimitBurst: SIGHUP is a common way of asking a process to restart, but it unhandled, it In this context, a clean exit means an exit code of 0, or one of the signals SIGHUP, SIGINT, SIGTERM or SIGPIPE, If set to on-success, it will be restarted only when the service process exits cleanly. Note also that a "successful exit" here is defined rather broadly: Since it is capable of restarting services on failure, they might as well include the option of restarting the service always, just in case someone needs it. In some sense, we might also ask why not include that option in systemd. Having systemd do the restarting makes for a cleaner implementation of the service itself. a service configured to only run for a fixed period of time or to serve fixed number of requests and to then stop to avoid any possible resource leaks. I don't know for sure what situation they had in mind for that feature, but we might hypothesise e.g. If set to always, the service will be restarted regardless of whether it exited cleanly or not, got terminated abnormally by a signal, or hit a timeout. Always pretty much does what it says on the lid: ![]() The rvice man page has a description of the values Restart= takes, and a table of what options cause a restart when. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |