service: add new RestartMode option

When this option is set to direct, the service restarts without entering a failed
state. Dependent units are not notified of transitory failure.

This is useful for the following use case:

We have a target with Requires=my-service, After=my-service.
my-service.service is a oneshot service and has Restart=on-failure in
its definition.

my-service.service can get stuck for various reasons and time out, in
which case it is restarted. Currently, when it fails the first time, the
target fails, even though my-service is restarted.

The behavior we're looking for is that until my-service is not restarted
anymore, the target stays pending waiting for my-service.service to
start successfully or fail without being restarted anymore.
This commit is contained in:
Richard Phibel
2023-07-06 14:33:52 +02:00
parent 5bc9ea070f
commit e568fea9fc
20 changed files with 129 additions and 1 deletions
+1
View File
@@ -95,6 +95,7 @@ int main(int argc, char **argv) {
test_table(scope_state, SCOPE_STATE);
test_table(service_exec_command, SERVICE_EXEC_COMMAND);
test_table(service_restart, SERVICE_RESTART);
test_table(service_restart_mode, SERVICE_RESTART_MODE);
test_table(service_result, SERVICE_RESULT);
test_table(service_state, SERVICE_STATE);
test_table(service_type, SERVICE_TYPE);