In the company I work for, I must have/implement the following functionality of a systemd service: - when a service stops with an exit code not 0, that is when it fails, it must be restarted. This is implemented, by using the option *Restart=on-failure*. Eventually, also *RestartSec=* can be used. - when the service is configured to restart itself (as above), the number of restarts count must be limited (example: 3 restart retries). At the moment, this can't be done, there aren't any options implemented for this situation, the service keeps restarting forever. - when a service is configured to restart itself on failure (as above), after the restart retries expire (example: after 3 restart retries), then if the service is still failed, some action could be taken (optionally), to run a command (something like ExecStopPost=). At the moment, this also can't be done.

So, for these last two features I created a patch, which adds two more options for a .service :
- *RestartRetries=n* (where n is the number of restart retries)
- *ExecPostRestarts=/some/cmd* (where the command "*/some/cmd*" will be executed after restart retries are finished).

The systemd's behavior is modified as follows:
- when service is in *auto-restart* state, each restart attempt is counted until the maximum restart retries are reached (specified via *RestartRetries* option); - when max. restart retries are reached and the option *ExecPostRestarts* isn't specified, the service enters *dead* state; - if a command is specified in *ExecPostRestarts* option, then after *auto-restart* state (when max. restart retries are reached) the service will enter a new state *post-auto-restart* and will remain in this state as long as the specified command is executing; - when post-auto-restart command ends execution, the service enters *dead* state.

We would appreciate if you can add this patch in your development tree. Currently this patch is made for systemd-16. If you agree we will send you the patch after following an IP review in our company.



Thanks in advance,
Cristian Patrascu
Wind River

_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to