<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#ffffff">
In the company I work for, I must have/implement the following
functionality of a systemd service:<br>
<style type="text/css">p { margin-bottom: 0.</style>- 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 <b>Restart=on-failure</b>.
Eventually, also <b>RestartSec=</b> can be used.<br>
- 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.<br>
- 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. <br>
<br>
So, for these last two features I created a patch, which adds two
more options for a .service :<br>
- <b>RestartRetries=n</b> (where n is the number of restart
retries)<br>
- <b>ExecPostRestarts=/some/cmd</b> (where the command "<b>/some/cmd</b>"
will be executed after restart retries are finished).<br>
<br>
The systemd's behavior is modified as follows:<br>
- when service is in <b>auto-restart</b> state, each restart
attempt is counted until the maximum restart retries are reached
(specified via <b>RestartRetries</b> option);<br>
- when max. restart retries are reached and the option <b>ExecPostRestarts</b>
isn't specified, the service enters <b>dead</b> state;<br>
- if a command is specified in <b>ExecPostRestarts</b> option, then
after <b>auto-restart</b> state (when max. restart retries are
reached) the service will enter a new state <b>post-auto-restart</b>
and will remain in this state as long as the specified command is
executing;<br>
- when post-auto-restart command ends execution, the service enters
<b>dead</b> state.<br>
<br>
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.<br>
<br>
<br>
<br>
Thanks in advance,<br>
Cristian Patrascu<br>
Wind River<br>
<br>
</body>
</html>