Run long operations asynchronously¶
Start a define, build, deploy or block operation without waiting, re-attach to it later, check its state, read its logs, and cancel a build.
Prerequisites¶
- A signed-in CLI in, or pointed at, the service's folder.
- Familiarity with the output contract.
Steps¶
-
Start the operation with
--async. The command returns as soon as the operation exists:{"schemaVersion": 1, "name": "operations/<id>", "done": false, "status": "running", "next": "alis operations wait operations/<id> --json"}Keep
name.nextis the exact wait command, including--cwdwhen you passed one. -
Re-attach and stream to completion when you are ready:
Progress streams on stderr; the final operation lands on stdout.
--timeout <duration>gives up waiting after a while; the operation keeps running server-side and the last stderr event carries thenextcommand to resume.--quiethides progress.--poll-interval <duration>changes the polling rate (default2s). -
Poll once instead of waiting:
done,status(running,succeeded,failed),version,notesandlogsUriare at the top level. -
Find operations you started earlier on this machine:
{"operations": [{"name": "operations/<id>", "type": "build", "target": "acme.shop.orders.v1", "startedAt": "<timestamp>", "next": "alis operations wait operations/<id> --json"}]}Only operations started by this CLI on this machine appear. With
--active, a row that cannot be read keepsstatus: "unknown"andinspectionError; an unreadable operation is not evidence that it stopped. -
Read the execution log when something fails:
Add
--package <pkg>when the operation is not in the local record. -
Cancel a build that should not continue:
Only builds can be cancelled. Wait for
stopped: truein the result before starting replacement work.
Interrupts and timeouts¶
Ctrl-C or a --timeout never cancels the server-side operation. It ends the stream with a warning event on stderr that names the resume command:
Run that next to re-attach. Do not pass the time with sleep loops or git ls-remote polling: wait blocks efficiently.
Related: alis operations, alis logs, Script the CLI with JSON.