Add PRE_START_SCRIPT, run after setup and before the server starts (#4293)

This commit is contained in:
u9g
2026-09-25 09:15:48 -05:00
committed by GitHub
parent 79a5346182
commit f3fe8284e5
3 changed files with 43 additions and 0 deletions
+16
View File
@@ -209,6 +209,22 @@ By default, the image finishes startup by exec'ing [mc-server-runner](https://gi
> [!TIP]
> The `SERVER_RUNNER` variable is expanded when passed to `exec` so that `mc-server-runner` can be wrapped by another executable that is mounted into the container.
## Pre-start script
To run something of your own after the image has finished setting up the server files and just before it starts the server, set `PRE_START_SCRIPT` to the path of an executable file that you have mounted into the container. The image runs it directly (not through a shell) and waits for it to finish. It runs as the user the server runs as, from the server's working directory, with the same environment the server gets. If it exits with a non-zero status, the container exits without starting the server.
For example, a script that waits for plugin jars that another process is still downloading:
```yaml
environment:
PRE_START_SCRIPT: /hooks/wait-for-plugins
volumes:
- ./hooks:/hooks:ro
```
> [!WARNING]
> The image does not guarantee that any particular command is available to the script, and it may change between image versions. Keeping the script working is up to you.
## Enable Flare Flags
To enable the JVM flags required to fully support the [Flare profiling suite](https://blog.airplane.gg/flare), set the following variable:
+6
View File
@@ -288,6 +288,12 @@ alternatively, you can mount: <code>/etc/localtime:/etc/localtime:ro
<td><code>false</code></td>
<td>⬜️</td>
</tr>
<tr>
<td><code>PRE_START_SCRIPT</code></td>
<td>Path to an executable run after setup and just before the server starts. The server is not started if it exits non-zero. See <a href="../configuration/misc-options/#pre-start-script">Pre-start script</a></td>
<td><code></code></td>
<td>⬜️</td>
</tr>
<tr>
<td><code>USE_FLARE_FLAGS</code></td>
<td>To enable the JVM flags required to fully support the <a href="https://blog.airplane.gg/flare">Flare profiling suite</a>.</td>