feat(cli): add graceful process abort

Using an AbortSignal and Promise.race we abandon running migrations that take longer to complete after the process is aborted than the given abortRespite period
This commit is contained in:
Joakim Carlstein 2024-01-22 10:53:01 +01:00 committed by Joakim Carlstein
parent ce15648251
commit a4da353d5a
17 changed files with 378 additions and 31 deletions

View file

@ -66,6 +66,8 @@ List the pending migrations that would be run without actually running them
### `-l, --limit <count>`
**type:** `number`
Limit the number of migrations to run. Can be combined with `--dry` which will show "pending" for the migrations that would be run if not in dry-run mode,
and "skipped" for the migrations that also haven't been run but won't because of the set limit.
@ -155,3 +157,10 @@ which is useful if you want to mark migrations as successful after running them
:::tip
See the <Link href="/guides/baseline/">Baseline guide</Link> for example usage of the `--no-execution` option
:::
### `--abort-respite`
**type:** `number`
**default:** `10`
Customize the number of seconds to wait before abandoning a running migration when the process is about to shutdown, for instance when the user presses `Ctrl+C` or when the container is being stopped (if running inside a container).

View file

@ -157,3 +157,16 @@ export default {
```
Will create new migration files with the `.ts` extension.
### `abortRespite`
**type:** `number`
**default:** `10`
Customize the number of seconds to wait before abandoning a running migration when the process is about to shutdown, for instance when the user presses `Ctrl+C` or when the container is being stopped (if running inside a container).
```js title="emigrate.config.js" {2}
export default {
abortRespite: 10,
};
```