Skip to content

Triggers: on

on says what starts a flow besides you. Three triggers exist: schedule, file and run. They work only while the daemon runs and the flow is registered and not paused. truss run ignores them: run means now.

on:
schedule:
- cron: "0 9 * * 1-5"
file:
paths: [inbox/]
run:
flow: build

You can combine them. Each run records why it started in TRUSS_TRIGGER: schedule, catch-up, file or run (manual for truss trigger and TRUSS Desktop, local for truss run).

A list. Each item is one schedule.

Key Required Default Meaning
cron yes Five fields: minute, hour, day of month, month, day of week.
timezone no this machine’s time zone An IANA zone such as Europe/Berlin or UTC.
missed no skip What to do with a time that passed while nothing watched the clock.
Form Example Means
value 30 18 * * * every day at 18:30
list 0 8,17 * * * at 08:00 and 17:00
range 0 9 * * 1-5 Monday to Friday at 09:00
step */15 * * * * every 15 minutes
names 0 9 * * mon-fri, 0 0 1 jan * three-letter weekdays and months
shortcut @hourly @daily @weekly @monthly @yearly the usual meanings

Sunday is 0 or 7. When both day fields are restricted, a day matches if either one does (0 0 13 * 5 means the 13th and every Friday), as in classic cron.

A laptop sleeps and is switched off at night. TRUSS never surprises you with a late run unless you ask.

missed The time passed while the machine was off, asleep or the daemon stopped
skip Nothing runs. The history shows a skipped run with the planned time.
run One catch-up run starts as soon as the daemon is back, however many times were missed.

A schedule counts as on time when it fires within two minutes of its planned time.

on:
file:
paths: [inbox/, "src/**/*.go"] # what to watch
ignore: ["**/*.tmp"] # changes that do not count
debounce: 5s # wait until changes stop

The daemon starts the flow once files under paths were created, changed or removed, and nothing changed for debounce. A burst of changes is one run.

Key Required Default Meaning
paths yes Folders (everything under them), files or patterns. Relative to the project folder, or absolute. * and ? match within a name, ** across folders. Use / on every system.
ignore no none Patterns of changes that do not count. A pattern that matches a folder keeps the daemon out of it.
debounce no 2s How long changes must stop, from 1s to 10m.
  • $TRUSS_CHANGED_FILES is the path of a file that lists the changed paths, one per line, relative to the project folder (absolute for an absolute pattern).
  • paths cannot go up with ... Write a folder outside the project as an absolute path.
  • Changes made while the daemon was stopped start nothing. The daemon counts changes from the time it starts.
  • .truss/state/ and .git/ are never watched. A flow that writes into a folder it watches starts itself: write elsewhere, or ignore the output.
  • A flow has at most one hook-started run at a time. Changes made while it runs start one more run when it ends. For a manual or scheduled run of the flow, flow.overlap decides.
  • The daemon looks every second, at no more than 10,000 matching files and 50,000 files and folders per flow. Narrow paths for big trees, and ignore folders such as node_modules. It does not follow links: name the real folder.
  • Patterns match names as written: *.jpg does not match A.JPG. A file counts as changed when its time or size changes.
  • A whole disk (/, C:/) and ~ cannot be watched. Use at most three ** per pattern. A file name with a line break or other control character is left out; the daemon log says so.
on:
run:
flow: build
status: succeeded # succeeded (default) | failed | any, or a list
Key Required Default Meaning
flow yes The name of the flow to follow.
status no succeeded How that run must have ended: succeeded, failed, any, or a list of them.

on.run can be a list to follow several flows.

  • A run of build that ended as asked starts this flow, whatever started build. A run that never started (for example cancelled while queued) starts nothing.
  • While a run of this flow that a hook started is queued or running, the next one waits and starts when it ends. Several waiting become one.
  • Flows that start each other in a loop stop after 10 runs in a row. The daemon log says so.

truss flows show <flow> lists a flow’s triggers under “Starts when”.