I have two services for an application:
- healthcheck- which check the health of a system and attempts restart when the validation fails.
- rollback- when multiple restart attempts fails to pass the healthcheck, it does the rollback to the previous version.
the unit file looks like this for health check:
[Unit]
Description=greenboot Health Checks Runner
Before=boot-complete.target
OnFailureJobMode=fail
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/libexec/greenboot/greenboot health-check
Restart=no
[Install]
RequiredBy=boot-complete.target
WantedBy=multi-user.target
and rollback
[Unit]
Description=Greenboot rollback
DefaultDependencies=no
Before=multi-user.target ostree-finalize-staged.service greenboot.service
Wants=local-fs.target
After=local-fs.target
ConditionNeedsUpdate=|/etc
ConditionNeedsUpdate=|/var
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/libexec/greenboot/greenboot rollback
Restart=no
[Install]
WantedBy=multi-user.target
rollback has other set of trigger conditions including a grub variable, How can I ensure the the health-check service does not run when rollback run with exit code 0.