Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

muelle.receive

Source: src/muelle/receive.py.

muelle-receive SITE

Run by webhook after the HMAC rule has passed, with the request body in
$MUELLE_PAYLOAD. Validates it against the Nix-declared site table, queues it in
the spool dir and detaches the worker. Announce and abort only update the
listing: no spool, no worker. Stdout is the HTTP response body; a
non-zero exit makes webhook answer 500 with the stderr message.

Rejected

class Rejected(Exception)

field

def field(payload: dict[str, Any], key: str) -> str
Reads KEY as a string; missing, null and false read as empty.

validate

def validate(payload: object, hook_site: str, config: Config, now: int) -> str
Checks a payload against the site table; returns the URL it deploys to ("" for a
teardown) or raises Rejected with a reason.

spool

def spool(state: StateDir, id: str, raw: str) -> None
Queues RAW for the worker. Creating the spool file is the replay gate: an id is accepted once.

notice

def notice(config: Config, id: str, job: dict[str, str], url: str) -> dict[str, str]
Records an announce (building in CI) or an abort (that build failed or was
cancelled), then refreshes the listing. An abort only fails the announce of the same
run that is still the newest job for its env/branch: a deploy that got further
already has its own state.

detach_worker

def detach_worker(config: Config, id: str) -> None
Runs the worker in a forked session that outlives this process.

The child must not keep webhook's stdout/stderr pipes open, or webhook
would wait for the deploy to finish before answering.

handle

def handle(
    raw: str,
    hook_site: str,
    config: Config,
    now: int,
    spawn: Callable[[Config, str], None] = detach_worker,
) -> dict[str, str]

main

def main(argv: list[str] | None = None) -> int