feat: optional restart exit code so a supervisor owns the relaunch (#2705)
Fixes #2700 (with #2704) A restart (`restart` console command, `AutoRestart`, `CrashGuard`) launches a copy of the server and exits. That copy is detached from the console it was started from: the shell takes the terminal back and console commands stop working. Under systemd or in a container it's killed as soon as the original process exits. - New setting `server.restartExitCode` (off by default). When it's set, a restart saves and shuts down as usual and then exits with that code, so a shell loop, systemd unit or container restart policy can start the server again on the same console. Values outside 1–255 log a warning and fall back to the current behaviour. - Fixes `CrashGuard` crash recovery never restarting the server. Since #1809, `Kill()` only records the request, and the unhandled-exception path called `DoKill()` without it. - Documents systemd, Docker and shell-loop setups in `dev-docs/server-requirements.md`.
This commit is contained in:
parent
577a4da60c
commit
eff9de0281
3 changed files with 55 additions and 2 deletions
|
|
@ -126,6 +126,36 @@ See the README for the full supported list. Two things are worth calling out:
|
|||
- **Linux kernel 6.1** or newer (Debian 12 and equivalents). io_uring is used where available, with
|
||||
automatic epoll fallback.
|
||||
|
||||
## Restarting under a supervisor
|
||||
|
||||
By default a restart (`restart` console command, `AutoRestart`, `CrashGuard` crash recovery)
|
||||
launches a fresh copy of the server and exits. That copy is detached from the console you started
|
||||
the server in, and a systemd unit or container kills it as soon as the original process exits.
|
||||
|
||||
If something else keeps the server running, let it do the relaunch instead. Set a restart exit code
|
||||
in `Distribution/Configuration/modernuo.json`:
|
||||
|
||||
```json
|
||||
"settings": {
|
||||
"server.restartExitCode": "75"
|
||||
}
|
||||
```
|
||||
|
||||
A restart then shuts down and saves as usual and exits with that code (1–255) instead of launching
|
||||
a copy. A normal `shutdown` still exits with `0`. `75` is a suggestion; any code your supervisor
|
||||
does not use for something else works. Then restart on that code:
|
||||
|
||||
- **systemd**: `Restart=on-failure` in the `[Service]` section.
|
||||
- **Docker**: `restart: on-failure` in Compose, or `--restart on-failure`.
|
||||
- **Shell loop** (Linux/macOS), keeps the server on the same terminal:
|
||||
```sh
|
||||
while :; do dotnet ModernUO.dll; [ $? -eq 75 ] || break; done
|
||||
```
|
||||
- **PowerShell** (Windows):
|
||||
```powershell
|
||||
do { dotnet ModernUO.dll } while ($LASTEXITCODE -eq 75)
|
||||
```
|
||||
|
||||
## Tuning for a small host
|
||||
|
||||
| Setting | Default | Why change it |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue