SERVER / SPAWN

Run a controlled process

spawn is a server-only declaration that runs an installed command through Dowe's Rust-owned process runtime. It binds the process result without executing Dowe source through Node.js.

Server documentation

MENTAL MODEL

Declare the result binding first

The name after spawn is the variable for the final process result. command and args remain separate, so Dowe does not parse a shell command string.

dowe
handler inspectMedia async req
  spawn ffmpeg command:"ffmpeg" args:["-version"] timeoutMs:5000 maxOutputBytes:65536
  return response json:{ ok:ffmpeg.ok stdout:ffmpeg.stdout stderr:ffmpeg.stderr }

BINDING

ffmpeg names the result that later statements can return, inspect, or use as a byte response.

COMMAND

command identifies the executable. args is an ordered array, never an implicit shell expression.

BOUNDARY

spawn is available only to server runtime code. Views and client targets cannot start processes.

OPTIONS

Bound output and process lifetime

Use timeoutMs and maxOutputBytes when a handler must wait for a tool. Use background:true only when the caller deliberately owns a long-lived helper.

dowe
init
  spawn encoder command:"ffmpeg" args:["-re","-i","input.mp4"] cwd:"/srv/media" background:true

timeoutMs and maxOutputBytes

Limit a waiting process and its captured stdout or stderr to protect the server request lifecycle.

Migration

Replace let ffmpeg = dowe.spawn with spawn ffmpeg. The legacy expression form is rejected with the current declaration syntax.