Skip to content

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
$ truss daemon start
daemon 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 first

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

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 invalid with 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.workdir changes that.
  • register --all takes 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.

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.

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.

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

The daemon reads ~/.truss/config.yaml each time it starts. The file is optional, and every setting has a default.

~/.truss/config.yaml
address: 127.0.0.1:7878 # where it listens; this machine only
max_runs: 4 # runs that execute at the same time
history: 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 config
file /home/me/.truss/config.yaml
SETTING VALUE SOURCE
address 127.0.0.1:7878 default
max_runs 2 config.yaml
history 200 default

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 install
login start installed: /home/me/.config/systemd/user/truss.service
the daemon is running under systemd and starts at every login
$ truss daemon uninstall
login 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 install from the truss you 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.
  • install accepts the options of daemon run (--address, --max-runs) and builds them in.
  • Do not use sudo or an administrator shell. The login item belongs to your own account.
  • uninstall removes only what install created. 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-linger once.
  • On Windows, some setups only let administrators create a task that runs at logon. If install says “access denied”, TRUSS does not work around it.
  • On Windows, run truss daemon stop before uninstall.

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] add Environment="PATH=/home/me/.local/bin:/usr/local/bin:/usr/bin:/bin", then systemctl --user restart truss.service. This survives running install again.
  • macOS: add the variables to the EnvironmentVariables dictionary of the plist, then launchctl bootout gui/$(id -u)/io.github.afri-bit.truss and launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/io.github.afri-bit.truss.plist. Running install again regenerates the file and drops your additions.
  • Windows: set a user variable with setx NAME value; the task sees it at the next logon.

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 was running when the daemon died is closed as failed at the next start; runs that were only queued start 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.log is set aside as daemon.log.1 at a start when it is over 10 MiB.

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_HOME at a shared folder.
  • Register only files that only you can change. The daemon runs what they say, as you.
  • truss desktop opens 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.