feat(deploy): systemd user unit + install script for membershipd
Add deploy/unibus-membershipd.service (Restart=always, binds both planes to 0.0.0.0 for LAN reachability), an idempotent deploy/install.sh that builds the binary, symlinks the unit, and enables+starts it, plus deploy/README.md with operate/health instructions. Restart=always is deliberate: a clean SIGTERM exits 0 and Restart=on-failure would not restart it, leaving the service silently dead (the sqlite_api gotcha). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build membershipd and install/enable/start it as a systemd user service.
|
||||
# Idempotent: safe to re-run after a code change to rebuild and restart.
|
||||
set -euo pipefail
|
||||
|
||||
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
UNIT="unibus-membershipd.service"
|
||||
USER_UNIT_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"
|
||||
|
||||
cd "$APP_DIR"
|
||||
|
||||
echo "==> building membershipd (CGO_ENABLED=0)"
|
||||
CGO_ENABLED=0 go build -o membershipd ./cmd/membershipd
|
||||
|
||||
echo "==> linking unit into $USER_UNIT_DIR"
|
||||
mkdir -p "$USER_UNIT_DIR"
|
||||
ln -sf "$APP_DIR/deploy/$UNIT" "$USER_UNIT_DIR/$UNIT"
|
||||
|
||||
echo "==> reloading systemd and (re)starting the service"
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable --now "$UNIT"
|
||||
# If the service was already running, enable --now does not restart it; do so to
|
||||
# pick up the freshly built binary.
|
||||
systemctl --user restart "$UNIT"
|
||||
|
||||
echo "==> status"
|
||||
systemctl --user --no-pager status "$UNIT" || true
|
||||
|
||||
echo
|
||||
echo "Health check:"
|
||||
echo " curl -fsS http://127.0.0.1:8470/healthz"
|
||||
Reference in New Issue
Block a user