#checking #tool #stampfile #flyweight #freshness

app stampiotic

A flyweight tool for checking stampfile freshness

1 stable release

1.0.0 Jan 31, 2023

#355 in Date and time

MIT license

6KB
55 lines

stampiotic

A flyweight tool for checking stampfile freshness.

Installation

Install from source with

$ cargo install stampiotic

You can build optimised binaries using Nightly's build-std feature, saving around 200 KiB.

$ cargo +nightly build --release
    -Z build-std=std,panic_abort
    -Z build-std-features=panic_immediate_abort
    --target x86_64-unknown-linux-gnu

Why?

Spinning up a shell (or worse, a Python or Perl script) takes substantially longer than invoking a small binary, so why bother? Some containers might not even include a shell by default. stampiotic has exactly one dependency: libc.

stampiotic is a particularly useful tool for implementing a watchdog timer in Kubernetes. Legacy services can just touch a stampfile periodically, which can then be checked using stampiotic as a periodic Kubernetes health check.

Usage

$ stampiotic max-age stampfile [...]

e.g.

$ stampiotic 60s /run/foo/foo-server.stamp 60s
$ stampiotic '30 min' make.stamp
$ stampiotic 1d long-process-1.stamp long-process-2.stamp
File "long-process-2.stamp" is too old (12345s > 86400s)
$ echo $?
1

Max-age parsing

Durations are parsed by humantime.

Unit Supported suffixes Definition
nanoseconds nsec/ns 10−9 s
microseconds usec/us 10−6 s
milliseconds msec/ms 10−3 s
seconds seconds/second/sec/s 1 s
minutes minutes/minute/min/m 60 s
hours hours/hour/hr/h 3600 s = 60 minutes
days days/day/d 86,400 s = 24 hours
weeks weeks/week/w 604,800 s = 7 days
months months/month/M 30.44 days = 2630016 s
years years/year/y 365.25 days = 31557600 s

Dependencies

~43KB