7.20. watchdog — Program Supervisor

One supervisor for any daslang program that needs to stay up. It restarts the child with bounded backoff, captures crashes into bundles, reports startup progress, and polls health. In-tree it supervises utils/dasllama-server (JIT) and the telegram dictation example (a baked exe).

It ships as a static executable, bin/watchdog (bin/Release/watchdog.exe in an MSVC tree): a standalone context on the full runtime that compiles nothing at run time, loads no shared module, and holds no lock on any file a deploy replaces. The same code runs under the interpreter for development.

7.20.1. Quick start

In a deployed bundle, beside the program:

./watchdog

From the source tree, point it at the program’s directory:

bin/watchdog --cwd utils/dasllama-server

or, under the interpreter:

daslang utils/watchdog/main.das -- --cwd utils/dasllama-server

What to supervise resolves in order, first match winning: command-line flags (--program, --script, --name, …); watchdog.json beside the executable (each key is a flag name with underscores and sets the default for that flag; unknown keys are a hard error); layout discovery (main.das beside bin/Release/daslangdaslang -jit main.das; exactly one program → that program, where a program is a *.exe file - a flat daspkg release bundle keeps the suffix on Linux too - or, on a Unix layout, an executable file with no extension, which is how the macOS .app names its exe; the watchdog’s own executable never counts; a main.das with no daslang in reach is refused, never traded for a program; anything ambiguous is an error, never a guess). Everything after -- goes to the child.

--tray (the tray key in watchdog.json) puts a status icon in the notification area: a mark badged by state, the status line as its tooltip and the menu’s first row, Open <name> for the page named by --tray-url (or the health URL’s origin), live while the health check is green, and Shutdown. --tray-icon <file> (the tray_icon key) replaces the stock disc with the program’s own mark - a PNG, or an ICO whose frames are PNG-compressed, square, up to 256 px - and the badge is drawn over it; a file it cannot use is logged as tray_icon_unavailable with the reason and the disc shows. Where no desktop can show an icon, the log says tray_unavailable and supervision runs without it.

See also

daspkg — Package Managerrelease_include_tool("watchdog") ships the executable inside a package release