Skip to content

Watchers

Long-running scripts kept alive inside a workspace's box, a poller, a sync, a queue reader, restarted when they exit.

Reading time
2 min read

How it works

A watcher is a script that should keep running in a workspace's box whether or not anyone has the workspace open: a poller, a sync, a queue reader. DevBench restarts one that exits and records each exit, with the output it died on, in the workspace's Watcher logs page (and tells its owner in the Inbox), so a watcher that quietly died is not something you find out about a week later, and the workspace's chat stays a conversation rather than a crash log.

A watcher can run continuously, on an interval, or at fixed times of day. Its script, its output and its run history are all readable from the page, the logs are the box's own stdout, and the run history is start-to-exit per run, which is what tells you whether "it is running" means "running" or "crash-looping".

Steps

Following along? Tick each number off as you go.
  1. Open Watchers from Automate in the top bar (or the search: Ctrl Ctrl, ⌘ ⌘ on a Mac).

  2. Press New watcher and name it.

  3. Paste the script.

    It runs in the workspace's box, with everything that box has.

  4. Choose how it runs, continuously, every N seconds, or at fixed times of day.

  5. Save it.

    It starts immediately unless you created it disabled.

  6. Open it later to read logs and runs.

    Logs are the script's own output; runs are start-to-exit, which is how you spot a crash loop.

  7. Use Stop to take it out of service; it stays stopped until you start it again.

  8. Open the workspace's Watcher logs page (under More ▾) to see every exit, failed start and restart.

    Click a watcher there to see only its entries and its live output.

Commands

The same job from a workspace's box, for people who live in the terminal.

devbenchinside the box
  • $ devbench watcher add <name> --script-file <path> --interval <n>Create one from inside the box.
  • $ devbench watcher listThis workspace's watchers and their status.
  • $ devbench watcher logs <name> --tail 100The watcher's own output.
  • $ devbench watcher runs <name>Its start-to-exit run history.
  • $ devbench watcher edit <name> --script-file <path>Change its code or schedule; a running watcher restarts with the new script.
Report a problem