Background Service
The Lattis daemon runs separately from the app window. It runs as a per-user background service. The OS starts it at login. On macOS and Linux, the OS also starts it again after a crash. On Windows, Task Scheduler does not do this: the app starts the daemon again while the app is open. The API stays available when the window is closed.
How Lattis registers the service
Section titled “How Lattis registers the service”At each launch, the installed app registers the service. If the entry is
missing or out of date, the app writes it again. There is no setting to turn
this on. The service is per-user and needs no sudo or administrator rights.
| Platform | Service entry |
|---|---|
| macOS | A LaunchAgent at ~/Library/LaunchAgents/com.lattis.daemon.plist |
| Linux | A systemd user unit at ~/.config/systemd/user/com.lattis.daemon.service |
| Windows | A Task Scheduler task named LattisDaemon |
The app then asks the OS to start the service. If the daemon does not answer after a few seconds, the app starts the daemon itself.
After an update, the app asks the OS to restart the daemon, so the new daemon
version runs. The app does this only when the daemon is the local service
daemon. A daemon on another host, or one reached through an ssh -L
forward, is not restarted: the app asks you first.
If another program holds the daemon port (for example an ssh -L forward),
the service daemon stops with no error, and the OS does not start it again.
These builds do not register the service. They start the daemon directly:
- Builds from source, including a bundle from
app/scripts/bundle-macos.sh. - On macOS, an app that is not in
/Applicationsor~/Applications. - An app started with
LATTIS_DATA_DIRorLATTIS_PORTset.
- macOS and Windows: the service writes its output to
daemon.login the data directory (see Configuration & Storage). - Linux: the output goes to the journal. Read it with
journalctl --user -u com.lattis.daemon.
The lattisd service command
Section titled “The lattisd service command”The daemon binary has a service command:
lattisd service status # show the entry, the program, and if the daemon runslattisd service install # register the service for this installlattisd service uninstall # remove the service entrystatus exits with 0 when the service is installed and running, and with
3 when it is not.
install refuses a binary that is not part of an installed app. Add --force
to register it anyway.
Turning the service off
Section titled “Turning the service off”lattisd service uninstall removes the entry. The app registers it again at
the next launch. To keep it off, set LATTIS_NO_SERVICE=1 in the environment
the app starts with. Then the app starts the daemon itself while it runs.
To stop the running daemon, use the Control API:
curl -X POST http://127.0.0.1:5288/control/shutdownAfter you remove Lattis
Section titled “After you remove Lattis”The Windows uninstaller removes the task. On macOS (drag to Trash) and on
Linux, the entry stays. Run lattisd service uninstall before you remove
the app. If the app is already gone, remove the entry by hand:
-
macOS:
Terminal window launchctl bootout gui/$(id -u)/com.lattis.daemonrm ~/Library/LaunchAgents/com.lattis.daemon.plist -
Linux:
Terminal window systemctl --user disable --now com.lattis.daemon.servicerm ~/.config/systemd/user/com.lattis.daemon.service
On Linux, a unit whose program is gone does nothing at login. On macOS, launchd tries to start the missing program and writes an error to the log.
Verifying
Section titled “Verifying”curl http://127.0.0.1:5288/health # {"status":"ok"} when runninglattisd service status