[systemd-devel] systemd restart patch
Cristian.Patrascu at windriver.com
Mon Feb 7 00:01:50 PST 2011
On 02/03/2011 11:19 PM, Michael Biebl wrote:
> 2011/2/3 Tomasz Torcz<tomek at pipebreaker.pl>:
>> On Thu, Feb 03, 2011 at 09:35:55PM +0100, Michael Biebl wrote:
>>> ExecStartOnFailure=/some/cmd (send an email or what not)
>> Isn't “OnFailure=send-email-to-admin.service” sufficent?
> Having to use a service file for this use case is imho cumbersome,
> especially since you can't pass information to that service afaik,
> e.g. via env variables.
> So this send-email-to-admin.service doesn't know which service it was,
> that failed and its last status code. Or am I misinformed here?
> Also, does OnFailure= work as I described with regard to Restart=on-failure?
On 02/03/2011 10:35 PM, Michael Biebl wrote:
> ExecStartOnFailure=/some/cmd (send an email or what not)
> If Restart=on-failure is not set, this command is executed when the
> starting the service has failed.
2011/2/3 Cristian Patrascu <Cristian.Patrascu at windriver.com>:
> - RestartRetries=n (where n is the number of restart retries)
Using "Restart=on-failure" and "OnFailure=some-other.service", the
specified service will be started for every restart that exits with
fail, of current service.
But we want to execute a command only after a service has already failed
"n" times. So we must have the following use-case:
- if "Restart=" is not set : suggestion regarding ExecStartOnFailure
should work fine (command will be executed when service fails);
- if "Restart=" is set to:
- "on-success" or "always": the service will be restarted as
long as it exits with success (ExecStartOnFailure not executed). But if
at any moment the service exits with failed, then the service should be
given "n" chances to be restarted and exit with success. If after a
restart retry (less than "n") the service exits with success, the
procedure repeats. But if "n" restarts have happened and the service
still failed, then the "ExecStartOnFailure" should be executed.
- "on-failed": the service will only be restarted when failed,
and then same as above, will be given "n" chances to restart and exit
with success. When "n" restarts have happened and still exited with
fail, executes "ExecStartOnFailure" command.
In this case, a better name for "RestartRetries" option would be
So, this is the desired functionality in case these new options are set.
More information about the systemd-devel