CLI 参考
pikeway runs stop
停止仍在排队或运行中的后台运行。
用法
bash
pikeway runs stop -r <run-id> [--json] pikeway runs stop <run-id>
说明
调用 POST /v1/runs/<id>/stop,并打印停止后的运行状态,通常为 STOPPED。如果运行恰好在停止过程中结束,则显示其最终状态。
- 只能停止后台运行(id 以
run_开头,用--async或--wait启动)。同步调用在命令返回前就已结束。 - 被停止的运行不会扣费,除非上游调用已经完成。
- 需要 key,且该运行必须属于同一账户。
参数
--run, -rstring必填后台运行的 id。也可以直接写在 stop 后面。
示例
bash
# stop a run you started with --async pikeway runs stop -r run_5f0c2b7e9a4d4e1b8c3a6f2d1e0b9a87 # positional id pikeway runs stop run_5f0c2b7e9a4d4e1b8c3a6f2d1e0b9a87 # stop every background run that is still running pikeway runs list --async --json | jq -r '.items[] | select(.status == "RUNNING" or .status == "QUEUED") | .runId' \ | xargs -n1 pikeway runs stop -r
输出
text
STOPPED · run run_5f0c2b7e9a4d4e1b8c3a6f2d1e0b9a87
--json
json
{
"runId": "run_5f0c2b7e9a4d4e1b8c3a6f2d1e0b9a87",
"status": "STOPPED"
}错误与退出码
| 退出码 | 错误信息 | 触发条件 |
|---|---|---|
| 2 | usage: pikeway runs stop -r <run-id> | 既没有 -r,也没有位置参数形式的 id。 |
| 1 | run not found (only async runs can be stopped) | id 不存在、属于其他账户,或者是同步调用的 id。 |
| 1 | run already finished | 该运行已不在排队或运行中。加 --json 时,details.status 给出其最终状态。 |
| 3 | no API key: run `pikeway keys add --label main --key pk-...`, set PIKEWAY_API_KEY, or pass --key | 没有 --key、没有 PIKEWAY_API_KEY,也没有已保存的当前 key。在发出请求之前就会检查。 |
| 3 | invalid or revoked API key — add a key with `pikeway keys add --label main --key pk-...` (or use --x402) | 网关返回 401(key 不存在、已吊销或已过期)。403 同样以 3 退出。 |
| 1 | cannot reach <gateway>: ECONNREFUSED | 无法连接网关(DNS、网络,或 PIKEWAY_API_BASE_URL 写错)。冒号后的错误码来自 Node。 |