os
The machine and this process: platform triple, CPU count, hostname, the running magus binary, and the two members that shadow Buzz's own (exit, sleep). Running OTHER processes lives in the proc module.
Naming convention: import the module under its bare name (
import "os"), reach members with a backslash, and call methods incamelCase:os\someMethod.
Methods
withEnv
Add env vars to subprocesses proc\exec / proc\shell start inside callback. Never touches the process's own environment - a lookup like os.env inside callback does not see them.
Signature: os\withEnv(env, callback) - source
| Parameter | Type | Optional | Description |
|---|---|---|---|
env |
map[string]string |
||
callback |
Callback |
platform
Return the Docker/OCI platform triple: (os, arch, variant).
Signature: os\platform() -> string, string, string - source
Returns: string, string, string
exit
Abort the current run with the given exit code - typically after logging an error. Does NOT call os.Exit (that would kill a shared daemon); it raises, ending the target, and the code becomes magus's process exit status.
Signature: os\exit(code) - source
| Parameter | Type | Optional | Description |
|---|---|---|---|
code |
int |
sleep
Pause for the given number of milliseconds (fractional allowed), matching Buzz's os.sleep. Cancellable: if the run is interrupted it returns early with the cancellation error rather than blocking.
Signature: os\sleep(ms) - source
| Parameter | Type | Optional | Description |
|---|---|---|---|
ms |
float64 |
numCpu
Return the number of logical CPUs available, for sizing a command's own internal parallelism (see os.with_slots).
Signature: os\numCpu() -> int - source
Returns: int
hostname
Return the host machine's name.
Signature: os\hostname() -> string - source
Returns: string
executable
Return the absolute path of the running magus binary. Pair it with fs.stat inside a long-lived watch loop to detect that the binary was rebuilt or upgraded underneath the process, which means any output it goes on to generate would be stale.
Signature: os\executable() -> string - source
Returns: string
retry
Call fn up to max times, retrying on error with exponential backoff; returns fn's value on success. opts: {backoff_ms:float (default 500), max_backoff_ms:float (default 30000)}.
Signature: os\retry(max, fn, [opts]) -> any - source
| Parameter | Type | Optional | Description |
|---|---|---|---|
max |
int |
||
fn |
Callback |
||
opts |
map[string]any |
yes |
Returns: any