
# Lifecycle

Actions on an already-created server: start and stop, reboot, auto-sleep and immediate sleep, wake, forced status refresh, tunnel repair via serial console. All endpoints are actions on a specific `:id`, and most return `{ "success": true }`.

Scope: `vibe:infra`

## Operations

- [Start server](./lifecycle/start.md) — `POST /v1/infra/servers/:id/start`
- [Stop server](./lifecycle/stop.md) — `POST /v1/infra/servers/:id/stop`
- [Reboot server](./lifecycle/reboot.md) — `POST /v1/infra/servers/:id/reboot`
- [Wake server](./lifecycle/wake.md) — `POST /v1/infra/servers/:id/wake`
- [Sleep now](./lifecycle/sleep-now.md) — `POST /v1/infra/servers/:id/sleep-now`
- [Configure auto-sleep](./lifecycle/sleep.md) — `PATCH /v1/infra/servers/:id/sleep`
- [Refresh status](./lifecycle/refresh.md) — `POST /v1/infra/servers/:id/refresh`
- [Repair tunnel](./lifecycle/repair.md) — `POST /v1/infra/servers/:id/repair`
- [Repair status](./lifecycle/repair-status.md) — `GET /v1/infra/servers/:id/repair-status`

## Scenarios

**Saving on idle nights (BLACKHOLE):**

1. Configure auto-sleep: [`PATCH /sleep`](./lifecycle/sleep.md) with `sleepAfterMinutes: 60`.
2. On the first request to the HTTPS subdomain or a call to [`/deploy`](/docs/infra/deploy/deploy), the server wakes automatically.
3. If you need to wake it ahead of time (for example, before a cron job) — [`POST /wake?wait=true`](./lifecycle/wake.md).

**Manual application restart without a full server reboot:**

1. Check that the tunnel is healthy: [`GET /v1/infra/servers/:id`](/docs/infra/servers/get) → `blackholeStatus: "CONNECTED"`.
2. Restart the service: [`POST /exec`](/docs/infra/deploy/exec) with `systemctl restart app`.

If the restart did not help — [`POST /reboot`](./lifecycle/reboot.md).

**The tunnel lost its connection (DISCONNECTED):**

1. Check: [`GET /v1/infra/servers/:id`](/docs/infra/servers/get) — `blackholeStatus: "DISCONNECTED"` on a `RUNNING` server.
2. Start the repair: [`POST /repair`](./lifecycle/repair.md).
3. Poll the progress: [`GET /repair-status`](./lifecycle/repair-status.md).
4. On completion — `blackholeStatus` returns to `CONNECTED`.

## See also

- [Servers](/docs/infra/servers) — creation and deletion.
- [Deploy API](/docs/infra/deploy) — deploy/exec/upload/logs work only when `blackholeStatus=CONNECTED`.
- [Root section — Infrastructure](/docs/infra) — status table, error codes.
