Skip to content

v0.1.0

Choose a tag to compare

@leninmehedy leninmehedy released this 19 Jun 05:02
· 7 commits to main since this release
a0aa7f9

daemonkit v0.1.0

First public release of daemonkit — a small, framework-neutral kernel for
building long-running Go daemons. It factors out the concerns every production
daemon re-implements (and usually gets slightly wrong): supervising work loops,
exposing health to operators, gating startup on host preconditions, and keeping
a durable audit trail — with a deliberately minimal dependency surface
(standard library + errorx + golang.org/x/sync/errgroup).

Packages

Package Import Responsibility
daemonkit github.com/automa-saga/daemonkit Supervised monitor loop, Unix-socket HTTP control plane, probe framework, sd_notify + watchdog
eventlog github.com/automa-saga/daemonkit/eventlog Append-only JSONL milestone/audit logger
filepruner github.com/automa-saga/daemonkit/filepruner Strategy-driven retention pruning of files

The three packages are independent and can be adopted individually.

Highlights

  • Supervised monitorsSupervisedMonitor runs each MonitorRunner in a
    restart loop with exponential back-off (5 s → 5 min cap), stable-run reset, and
    a MonitorDegraded escalation after repeated crashes. Clean shutdown vs. crash
    is unambiguous.
  • Operator-first control plane — a net/http server on a Unix domain socket
    exposes /health (liveness) and /status (live per-monitor state via an
    injected StatusFn), plus component-scoped routes. Local-only by construction,
    no port or auth to manage.
  • Health-carrying heartbeat — opt-in periodic MonitorHeartbeat records
    (with healthy + connectivity details for ConnectivityMonitors), so remote
    observability can alert on the absence of a signal — catching the
    alive-but-wedged case that liveness alone misses.
  • Probe framework — concurrent prerequisite checks (Probe,
    CompositeProbe, built-in disk probes) that fail before partial work with a
    stable, operator-actionable reason/resolution.
  • systemd integrationNotifyReady / NotifyStopping, plus an opt-in
    Watchdog keepalive for WatchdogSec= units (no go-systemd dependency).
  • Audit & retentioneventlog writes fsync'd, append-only JSONL
    milestones with required-field validation; filepruner enforces age/size
    retention with a hard cap and protects files whose eligibility is uncertain.
  • Backend-agnostic logging — drives log/slog; silent by default
    (slog.DiscardHandler), pluggable into any handler (e.g. logx for
    zerolog + lumberjack) and exportable to OTLP via a local collector.

Requirements

  • Go 1.26+

Install

go get github.com/automa-saga/daemonkit@v0.1.0