Skip to main content

processes.toml

A processes.toml lists the programs to supervise, one [[process]] table each. wasmrun ps start reads ./processes.toml unless --config names another. Relative paths are relative to the file.

The whole file is checked before anything starts: a missing file, an unknown field, a bad address or a malformed network rule is reported by ps start, not discovered later as a program that keeps crashing.

[[process]]
name = "api"
script = "server.js"
cwd = "app"
args = ["--verbose"]
env = { NODE_ENV = "production" }
listen = "127.0.0.1:8080"
allow_net = ["api.example.com:443"]
restart = "on-failure"
max_memory_mb = 128

What to run​

Exactly one of these:

FieldWhat
wasmA WASI module to run with exec mode's interpreter
scriptA JavaScript file to run on wasmhub's nodejs runtime, which is downloaded once and cached. The path is relative to cwd, and the program sees cwd as /

Fields​

FieldDefaultWhat
namerequiredLetters, digits, - and _. Names the program in every command and its log file
args[]Arguments after the program
cwdthe file's directory, for a scriptA directory the program sees as /. A wasm program has none unless this is set
dirs[]More directories, as HOST[:GUEST], the same as wasmrun exec --dir
env{}Environment variables. The program sees only these, not the supervisor's
listennoneAn address the host binds and hands to the program (wasmrun exec --tcplisten). WASMHUB_LISTEN_FD and WASMHUB_LISTEN_ADDR say where it is
allow_net[]Outbound destinations the program may reach (wasmrun exec --allow-net). Without any, it has no network
restarton-failurealways, on-failure (a non-zero exit or a signal), or never
max_restarts10Restarts allowed within restart_window_secs before the program is marked errored
restart_window_secs60The window max_restarts counts within
backoff_ms500The delay before a restart. It doubles for each run in a row that lasted under 10 seconds
max_backoff_ms30000The most the delay grows to
max_memory_mb256The program's linear memory cap; 0 is no cap
max_fuel0WASM instructions before the program is stopped; 0 is no cap
log_max_mb10The log's size before it is rotated
log_files3Rotated logs kept beside the live one
autostarttrueStart with the supervisor. false registers it stopped, for ps start <name>

Restarts in practice​

With the defaults, a program that exits with code 3 straight away is started again after 0.5 s, then 0.5 s, 1 s, 2 s, 4 s and so on, up to 30 s. After 10 restarts within a minute it is marked errored, with the reason in ps status and its log, and stays stopped until wasmrun ps start <name>, which also forgets the earlier failures.

A program that exits 0 under on-failure has finished its job: it is marked exited and not restarted. Under always it is restarted after the base delay.