Skip to content

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 daemon
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=%h/.local/bin/khiipd serve
Restart=on-failure
RestartSec=5
[Install]
WantedBy=default.target

Replace ExecStart with your real which khiipd path (e.g. a virtualenv’s bin/khiipd), then enable it:

Terminal window
systemctl --user daemon-reload
systemctl --user enable --now khiip # start now, and on every login
loginctl enable-linger "$USER" # keep running without an active login session
systemctl --user status khiip # confirm it's up
journalctl --user -u khiip -f # follow logs

macOS — 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:

Terminal window
launchctl load ~/Library/LaunchAgents/ai.khiip.daemon.plist # start now, and on login
launchctl list | grep khiip # confirm it's loaded
tail -f ~/Library/Logs/khiip.log # follow logs
launchctl unload ~/Library/LaunchAgents/ai.khiip.daemon.plist # stop

Both 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.