https://github.com/zombiezen/health-notify
Helper for systemd services to run a health check before starting dependent units
https://github.com/zombiezen/health-notify
Last synced: about 1 year ago
JSON representation
Helper for systemd services to run a health check before starting dependent units
- Host: GitHub
- URL: https://github.com/zombiezen/health-notify
- Owner: zombiezen
- License: apache-2.0
- Created: 2024-03-29T00:20:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-29T00:45:10.000Z (over 2 years ago)
- Last Synced: 2025-02-08T21:49:01.665Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# health-notify
`health-notify` is a small helper program for systemd services
that runs a health check program periodically on startup until the check program succeeds
and then notifies systemd using [`sd_notify`][].
This is useful for deploying programs that do not support [socket activation][]
and having them behave with other services
that depend on the program already listening for a socket.
[`sd_notify`]: https://0pointer.de/blog/projects/socket-activation.html
[socket activation]: https://0pointer.de/blog/projects/socket-activation.html
## Usage
HTTP-based health check:
```ini
[Unit]
Wants=local-fs.target network-online.target
After=local-fs.target network-online.target
[Service]
# Wrap your program arguments in health-notify.
# Everything before the first semicolon are the main program arguments.
# Everything after the first semicolon specify the health check program,
# which should exit with status code 0 on success.
ExecStart=/usr/local/bin/health-notify /usr/local/bin/my-server --port=8080 \; /usr/bin/curl -fsSL http://localhost:8080
# Use Type=notify to have systemd wait until a notification
# to mark the unit as started.
Type=notify
Restart=always
```
TCP-based health check:
```ini
[Unit]
Wants=local-fs.target network-online.target
After=local-fs.target network-online.target
[Service]
ExecStart=/usr/local/bin/health-notify /usr/local/bin/my-server --port=8080 \; /usr/bin/nc -z localhost 8080
Type=notify
Restart=always
```
## License
[Apache 2.0](LICENSE)