https://github.com/davidrjonas/condemn
A curl-able dead man's switch in Rust
https://github.com/davidrjonas/condemn
deadmanswitch http monitoring redis rust warp
Last synced: 2 months ago
JSON representation
A curl-able dead man's switch in Rust
- Host: GitHub
- URL: https://github.com/davidrjonas/condemn
- Owner: davidrjonas
- Created: 2019-02-13T17:39:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-28T06:09:27.000Z (about 6 years ago)
- Last Synced: 2025-01-29T05:28:45.633Z (4 months ago)
- Topics: deadmanswitch, http, monitoring, redis, rust, warp
- Language: Rust
- Size: 147 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Condemn
=======A curl-able [dead man's switch](https://en.wikipedia.org/wiki/Dead_man%27s_switch).
Call this service at the start of a process and at the end. If the second call never arrives, be notified of the failure.
Client Usage
------------At the beginning of your script call condemn with a deadline. `deadline` will accept durations like `15days 2min 2s`. See Durations for more info.
```bash
curl http://condemn.example.net/myscriptname?deadline=1h
```At the end of your script call condemn again with the same path. Include a deadline and optional window if you want to ensure the script runs again, for instance a cron job.
```bash
curl http://condemn.example.net/myscriptname?deadline=25h&window=2h
```If condemn is called again for your scriptname less than 23h for now it will notify that it started early. If there has been no call within the next 25 hours it will notify that the script is dead.
Durations
---------Will accept,
- nsec, ns -- microseconds
- usec, us -- microseconds
- msec, ms -- milliseconds
- seconds, second, sec, s
- minutes, minute, min, m
- hours, hour, hr, h
- days, day, d
- weeks, week, w
- months, month, M -- defined as 30.44 days
- years, year, y -- defined as 365.25 daysSet up
------Docker image available at https://hub.docker.com/r/davidrjonas/condemn
### Configuration
```
condemn 0.4.0
David JonasUSAGE:
condemn [OPTIONS]FLAGS:
-h, --help Prints help information
-V, --version Prints version informationOPTIONS:
-f, --db-file Path to persistent data file [env: DB_FILE=] [default: condemn.json]
-l, --listen The IP and port to listen on. [env: LISTEN=] [default: 0.0.0.0:80]
-n, --notify ... The notifiers to use. May require other options to be set, such as
`--notify-command` or `--sentry-dsn`. [env: NOTIFY=] [possible values:
command, sentry]
-c, --notify-command Command to run on notify. CONDEMN_NAME env var will be set. CONDEMN_EARLY
env var will be set to the number of seconds, 0 if deadlined. [env:
NOTIFY_COMMAND=]
-r, --redis-url The URL for Redis with database; redis://host:port/db [env: REDIS_URL=]
[default: redis://127.0.0.1:6379]
--sentry-dsn Configures `sentry` notifier. If notify includes 'sentry', `sentry-dsn` is
required. [env: SENTRY_DSN=]
-s, --store Which storage type to use. May require other options to be set, such as
`--redis-url` or `--db-file`. [env: STORE=] [default: memory] [possible
values: memory, disk, redis]
```Contributing
------------Pull requests welcome!
Notifiers are easy to add. Just implement the `Notifier` trait and add an entry to main() for configuration. See `sentry` as an example.
Future improvements
-------------------- [ ] Test(s)
- [X] Sentry notifier
- [ ] Basic auth with username as prefix to all keys
- [ ] Other notifiers like Slack, OpsGenie, webhook
- [X] Use a transaction with redis / pipeline
- [X] Refactor for readability
- [ ] Add client ip to notifies, other additional context the client may supply, like &ctx={"a":"b"} or &ctx[a]=b&ctx[c]=d