Autostart (launchd / systemd)
For a daemon that restarts on boot or crash, run khiipd serve under your OS process
manager. Find the absolute path to khiipd first with which khiipd — neither systemd
nor launchd inherits your interactive shell PATH, and a virtualenv install puts the
binary under that env’s bin/. Keep your per-source credentials in
~/.config/khiip/config.toml rather than environment variables: the daemon reads that file
no matter how it’s launched, which sidesteps the fact that service managers don’t inherit
your shell environment. (KHIIP_HOME is a dev/test override only — production services
should not set it.)
Linux — systemd user service
Write ~/.config/systemd/user/khiip.service:
[Unit]Description=Khiip capture daemonAfter=network-online.targetWants=network-online.target
[Service]ExecStart=%h/.local/bin/khiipd serveRestart=on-failureRestartSec=5
[Install]WantedBy=default.targetReplace ExecStart with your real which khiipd path (e.g. a virtualenv’s bin/khiipd),
then enable it:
systemctl --user daemon-reloadsystemctl --user enable --now khiip # start now, and on every loginloginctl enable-linger "$USER" # keep running without an active login sessionsystemctl --user status khiip # confirm it's upjournalctl --user -u khiip -f # follow logsmacOS — launchd agent
Write ~/Library/LaunchAgents/ai.khiip.daemon.plist (replace the /Users/you/… paths):
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict> <key>Label</key> <string>ai.khiip.daemon</string> <key>ProgramArguments</key> <array> <string>/Users/you/projects/khiip/.venv/bin/khiipd</string> <string>serve</string> </array> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/> <key>StandardOutPath</key> <string>/Users/you/Library/Logs/khiip.log</string> <key>StandardErrorPath</key> <string>/Users/you/Library/Logs/khiip.err.log</string></dict></plist>Then load it:
launchctl load ~/Library/LaunchAgents/ai.khiip.daemon.plist # start now, and on loginlaunchctl list | grep khiip # confirm it's loadedtail -f ~/Library/Logs/khiip.log # follow logslaunchctl unload ~/Library/LaunchAgents/ai.khiip.daemon.plist # stopBoth services bind 127.0.0.1:8478 by default. To reach the daemon from another machine,
add --host 0.0.0.0 to the serve arguments and read the
binding caution first.
See Self-hosting Khiip for install, data paths, sync, backup, and upgrades.