The daemon
truss run is enough to run a flow by hand. The daemon is a small background service that adds
what needs someone to stay awake: schedules, file and flow hooks, a queue, a history, and one place
where the command line and TRUSS Desktop see the same runs.
You start it yourself, and nothing else starts it. TRUSS Desktop cannot start or stop it.
| You want to | Do you need the daemon? |
|---|---|
Run a flow now, in your terminal (truss run) |
No |
| Run flows on a schedule, on file changes, or after another flow | Yes |
| Keep a history of runs, and see them in TRUSS Desktop | Yes |
| Get notifications for flows that run by themselves | Yes |
Start, check and stop
Section titled “Start, check and stop”$ truss daemon startdaemon started (pid 4242, 127.0.0.1:7878)
$ truss daemon status # running or not, how busy, and whether it starts at login$ truss daemon logs -n 20 # its own log; works when it is stopped$ truss daemon stop # stop it; add --wait to let runs finish firsttruss daemon status exits 1 when the daemon is not running, so a script can test it.
truss daemon run runs it in the terminal, for debugging.
Registering flows
Section titled “Registering flows”The daemon only runs flows you tell it about. A registration is a name and a path. The file stays where it is and stays the source of truth.
$ truss register nightly # .truss/flows/nightly.yaml of this project$ truss register ./other/x.yaml # any flow file, by path$ truss register --all # every flow of this project$ truss unregister nightly # forget it; the file and the history stay- The daemon re-reads a registered file before every run and notices an edit within a second: change the steps, the schedule or the name, save, done. Nothing to restart or register again. On a network or synced folder it can take longer.
- When the file changes
flow.name, the daemon shows the new name and keeps the history. Commands accept the new name and the name it was registered under. Scripts should use the registered name. To change it, unregister and register again with--name. - A name already used by another file is refused, with a hint to use
--name. - A file that becomes invalid is shown as
invalidwith the reason, and does not run until fixed. - A flow in a project runs its steps in the project folder. Any other file runs in its own folder.
flow.workdirchanges that. register --alltakes every flow the project holds, including files someone else committed. Use it only in projects you trust: the daemon runs what a file says, as you.
Schedules and hooks
Section titled “Schedules and hooks”A registered flow starts on its own through on.schedule, on.file and
on.run. The daemon checks the clock every second.
When the machine was off at a planned time, missed: skip records a skipped run and
missed: run runs once as soon as the daemon is back. Details: Triggers.
truss pause <name> stops a flow’s schedules and hooks; manual runs still work. Times that pass
while it is paused are not missed runs, and truss resume <name> counts from now.
truss schedules lists every schedule and when it runs next. truss flows show <flow> lists a
flow’s triggers.
How many runs at once
Section titled “How many runs at once”Three limits work together:
| Limit | Set with | Default | Controls |
|---|---|---|---|
| Runs at once | max_runs in the settings |
4 | How many runs execute in parallel, across all flows. |
| Overlap | flow.overlap in the file |
queue |
Whether two runs of the same flow may overlap, wait, or the second is skipped. |
| Steps at once | flow.concurrency in the file |
1 | How many steps of one run execute in parallel. |
Runs that cannot start yet are queued and start in the order requested. The queue survives a
restart.
Runs and their states
Section titled “Runs and their states”$ truss trigger nightly --follow # start a run now and watch it$ truss runs # the newest runs$ truss cancel <run-id> # end a queued or running run| Run state | Meaning |
|---|---|
queued |
Waiting for a free slot or for an earlier run of the same flow. |
running |
Steps are executing. |
succeeded |
No step failed the run. A step with continue-on-error can fail and the run still succeeds. |
failed |
A step failed; the note names it. |
cancelled |
You cancelled it, or the daemon stopped while it ran. |
skipped |
Requested but never started: a missed schedule, or overlap: skip. |
A step is pending, running, succeeded, failed, stopped (ended because another step
failed), cancelled or skipped (never started: the run ended first, an if was false, or a step
it needs did not succeed).
The trigger says why a run exists: manual, schedule, catch-up, file, run, or local
(a run from your terminal with truss run --track, which only reports to the daemon).
truss run --track runs in your shell as usual and also appears in truss runs and TRUSS Desktop.
It needs the daemon, and it never starts it.
Settings
Section titled “Settings”The daemon reads ~/.truss/config.yaml each time it starts. The file is optional, and every
setting has a default.
address: 127.0.0.1:7878 # where it listens; this machine onlymax_runs: 4 # runs that execute at the same timehistory: 200 # finished runs kept, with their logs| Setting | Default | Environment variable | Flag of truss daemon start |
|---|---|---|---|
address |
127.0.0.1:7878 |
TRUSS_DAEMON_ADDRESS |
--address |
max_runs |
4 |
TRUSS_DAEMON_MAX_RUNS |
--max-runs |
history |
200 |
TRUSS_DAEMON_HISTORY |
--history |
A flag wins over the environment variable, which wins over the file, which wins over the default. A setting TRUSS does not know, or a value it cannot use, stops the daemon from starting with an error that names the setting. Changes apply the next time the daemon starts.
truss daemon config shows what the daemon would use and where each value comes from
(--json for a script):
$ truss daemon configfile /home/me/.truss/config.yaml
SETTING VALUE SOURCEaddress 127.0.0.1:7878 defaultmax_runs 2 config.yamlhistory 200 defaultStarting at login
Section titled “Starting at login”truss daemon start does not survive a restart. One command makes your system start the daemon at
every login, with no administrator rights:
$ truss daemon installlogin start installed: /home/me/.config/systemd/user/truss.servicethe daemon is running under systemd and starts at every login
$ truss daemon uninstalllogin start removed: /home/me/.config/systemd/user/truss.service| System | What install creates |
|---|---|
| Linux | A systemd user unit, ~/.config/systemd/user/truss.service. Output: journalctl --user -u truss. |
| macOS | A launchd agent, ~/Library/LaunchAgents/io.github.afri-bit.truss.plist. Output: daemon.log in the TRUSS home. |
| Windows | A Task Scheduler task, truss-daemon-<user>, run at logon. A console window stays open; output is not saved. |
Things to know:
- Run
installfrom thetrussyou want to keep: its path is what gets recorded. It refuses a program in a temporary folder. Run it again after you move or upgrade the program. installaccepts the options ofdaemon run(--address,--max-runs) and builds them in.- Do not use
sudoor an administrator shell. The login item belongs to your own account. uninstallremoves only whatinstallcreated. A unit or task with that name that you wrote yourself is left alone.- On Linux the daemon runs only while you have a session. To have schedules fire without logging
in, run
loginctl enable-lingeronce. - On Windows, some setups only let administrators create a task that runs at logon. If
installsays “access denied”, TRUSS does not work around it. - On Windows, run
truss daemon stopbeforeuninstall.
The environment of a login-started daemon
Section titled “The environment of a login-started daemon”A daemon started at login has the login environment, not what your shell profile (.bashrc,
.zshrc, PowerShell profile) sets up. PATH is shorter and variables you export in the profile
are missing. Steps inherit this environment.
Put what a flow needs in its env (PATH: /usr/local/bin:${PATH}). To give the daemon more:
- Linux:
systemctl --user edit truss.service, then under[Service]addEnvironment="PATH=/home/me/.local/bin:/usr/local/bin:/usr/bin:/bin", thensystemctl --user restart truss.service. This survives runninginstallagain. - macOS: add the variables to the
EnvironmentVariablesdictionary of the plist, thenlaunchctl bootout gui/$(id -u)/io.github.afri-bit.trussandlaunchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/io.github.afri-bit.truss.plist. Runninginstallagain regenerates the file and drops your additions. - Windows: set a user variable with
setx NAME value; the task sees it at the next logon.
Where the daemon keeps things
Section titled “Where the daemon keeps things”Everything is under the TRUSS home, ~/.truss unless TRUSS_HOME says otherwise. The folder is
private to your user.
| Path | Holds |
|---|---|
config.yaml |
Your settings. Optional. |
registry.json |
Registered flows. |
secrets.json |
Stored secrets, in plain text (0600). See truss secret. |
runs/<run-id>/run.log |
The log of a run, the same text truss run prints. |
runs/<run-id>/run.json |
The status and steps of a run. |
pipelines/<name>/ |
The flow’s data folder, TRUSS_DATA_DIR. |
pipelines/<name>/cache/ |
Its cache folder, TRUSS_CACHE_DIR. |
daemon.log |
The daemon’s own log. |
daemon.json, clock.json |
The running daemon’s address and token, and when the scheduler last looked at the clock. Internal. |
Runs of truss run do not use this folder. They write into the project, in .truss/state/<name>/.
- The newest 200 runs are kept (
history). A run that wasrunningwhen the daemon died is closed asfailedat the next start; runs that were onlyqueuedstart again. - TRUSS never deletes the data and cache folders, not when a run ends and not when you unregister
the flow. To empty a cache, run
truss cache clear <name>. To remove all of a flow’s data, delete~/.truss/pipelines/<name>. - A run’s log keeps at most 64 MiB of step output; after that the log says so, and the summary is
still written.
daemon.logis set aside asdaemon.log.1at a start when it is over 10 MiB.
Security
Section titled “Security”The daemon runs your commands, so it is careful about who may ask.
- It listens on this machine only, and refuses any other address.
- Every request needs a token that changes at each start. The token is in a file only you can read
on Linux and macOS. On Windows that file has the permissions of its folder: keep the TRUSS
home inside your user profile (the default), and do not point
TRUSS_HOMEat a shared folder. - Register only files that only you can change. The daemon runs what they say, as you.
truss desktopopens your browser with the token in the address. On a shared machine, other users can see it in the process list for a moment.
Anyone who can read your home folder can control the daemon. That is the same trust as your shell.