# Restart the engine in its own process (owner only): it applies the settings waiting for a restart and the settings file's edits. With dry_run, it says what a restart would do and whether it can.

`POST /datanotes/restart/` (operation `restart_engine`)

The engine checks first that the next start will succeed: the folder exists, the settings file holds a JSON object the engine accepts, with an owner token, and the new port is free. When it would fail, the answer is 409 with the problems, and nothing stops. Otherwise it answers at once, then the requests under way finish and new ones get 503 (the engine is restarting). When a request still runs after 30 s, the restart is cancelled and the engine serves again (`last_cancelled`). The lock is kept. Poll the dry run until `restarting` is false: a new `started_at` then means the restart is done, the same one with `last_cancelled` that it was cancelled. The new engine answers a moment before it has finished starting, with a new `started_at` and `restarting` still true. A new port or owner token applies. A start that still fails ends the process with exit code 1. A named token is refused (403), even with `maintain`. A host that cannot restart does not serve the route (404).

## Request body

`application/json`

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `dry_run` | `boolean` | no | `false` | Only say what a restart would do. |

## Responses

| Status | Description | Body |
| --- | --- | --- |
| 200 | Done. | `EngineRestart` (application/json) |
| 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
| 401 | Missing or wrong bearer token. | `Error` (application/json) |
| 403 | A named token beyond its permissions (the engine's administration, tables outside its `write` patterns, schema changes without `ddl`). | `Error` (application/json) |
| 409 | A restart is already under way, or the next start would fail (problems): nothing stopped. | `Error` (application/json) |
| 500 | Unexpected error. | `Error` (application/json) |

The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
