Running as a service
pm daemon runs in the foreground, so a daemon started from a shell dies with
that shell. On a machine you want to keep reachable, put it under a service
manager.
There is no unit generator for the daemon. pm worker --systemd generates one
for a worker, because enrolling a worker is a thing you do once on a machine you may
never log into again; a controller is the machine you are sitting at. Write the
unit yourself, and the one below is a complete starting point.
A user unit
Section titled “A user unit”[Unit]Description=Puppet MasterAfter=network-online.target
[Service]Type=simpleExecStart=/usr/local/bin/pm daemonRestart=on-failureRestartSec=5KillSignal=SIGINTTimeoutStopSec=30
[Install]WantedBy=default.targetsystemctl --user daemon-reloadsystemctl --user enable --now pmloginctl enable-linger "$USER"A user unit is right here, because the daemon runs agents as you, with your files, your SSH keys and your agent CLI logins. A system unit running as root would be a different and worse thing.
loginctl enable-linger matters on anything headless: a user manager only runs
while the user is logged in, so without it the service stops at logout.
Two more things a user unit does not get for free:
PATH. The daemon starts your agent CLIs, and a service manager’s environment is not your shell’s. Ifclaudeorcodexlives somewhere a bare login would not find, setEnvironment=PATH=...in the unit, or the spawns will fail with the agent not found on a machine where it plainly is.XDG_CONFIG_HOMEand friends, if you have relocated any of them in a shell startup file. A value set only in a shell startup file is not in the user manager’s environment.
There is no launchd equivalent in the tool. Run pm daemon from a terminal, or
write a launch agent yourself.
What to back up
Section titled “What to back up”Three things, and the second is the one people forget:
| Path | Why |
|---|---|
pm.db |
everything: sessions, items, plans, reviews, workers, settings |
pm.db.secret |
the key that opens the sealed columns in pm.db |
scrollback/ |
what ended sessions printed, if you want to keep it |
A database restored without its secret opens, and everything in it works except the sealed columns: provider API keys and device push tokens come back as something nothing can open. Back them up together or the restore is a surprise.
Both files are mode 0600 and the directories around them 0700. Keep the
backup at least as private — it holds sealed credentials, a password hash, and
every session’s reported activity.
Restoring
Section titled “Restoring”Stop the daemon, put both files back where they were, and start it. The schema migrates forward on open, so a backup from an older build restores into a newer one.
The reverse does not work: a database written by a newer build is refused
rather than opened, because a schema it does not understand is not something it
can safely guess at. Restoring into an older pm means installing the newer one
again.
Upgrading
Section titled “Upgrading”pm update # install the newest published buildsystemctl --user restart pmpm update replaces the binary. It does not restart the daemon, and the daemon
does not update itself on a timer, because restarting it ends the local sessions
it is holding — that is your decision rather than an update’s. It does check
every six hours and say when a newer build is published.
Workers are the other way round: each one follows its controller’s build on its own, waits to be idle before restarting into it, and needs nothing from you.
→ Updates
What to check after a restart
Section titled “What to check after a restart”The daemon prints what it bound and which forward mount is in effect, which is the fastest way to confirm a unit’s flags actually took:
web ui at http://127.0.0.1:7676/forwards mounted by path prefix, each at /forwards/<id>/Sessions that were running come back on their own — local ones are resumed, and sessions on other machines were never this process’s to lose.
Exposing it past loopback
Section titled “Exposing it past loopback”Both listeners default to 127.0.0.1. Binding either one wider is a decision
with consequences, and they are set out on their own page rather than here.