Panel/docs/features/SERVER_CONTENT_APPLICATION_HOOKS.md
2026-06-18 12:11:47 -05:00

114 lines
3 KiB
Markdown

# Server Content Application Hooks
Server Content Application Hooks let installed server content manage companion
applications such as BEC, Big Brother Bot, Discord bridges, RCON tools, and log
watchers as part of the game server lifecycle.
The application files may live wherever the game requires them. GSP lifecycle
metadata lives under each server home:
```text
_gsp_content/
hooks/
generated/
runtime/
```
## Category And Hook Metadata
All server content uses the scripted installer workflow.
`Server-side Application` is a category used for sorting/filtering, plus a
startup-hook metadata preset. Any content item with startup-hook metadata
enabled writes a JSON hook manifest to:
```text
_gsp_content/hooks/<app>.json
```
The agents read these manifests during server startup. The actual files for the
content item may be installed anywhere the game requires them.
## Hook Manifest
```json
{
"name": "BEC",
"enabled": true,
"platform": "windows",
"working_dir": "bec",
"start_command": "BEC.exe -f Config.cfg",
"stop_command": "",
"start_timing": "before_server",
"stop_with_server": true,
"watch": true,
"critical": true,
"kill_game_if_app_exits": false,
"restart_app_if_exits": true,
"pid_name": "bec",
"app_name": "BEC.exe",
"description": "Battleye Extended Controls watchdog for DayZ/Arma servers"
}
```
Supported `platform` values are `windows`, `linux`, and `both`.
Supported `start_timing` values are `before_server` and `after_server`.
## Runtime PID File
Agents write hook runtime PIDs to:
```text
_gsp_content/runtime/server_content.pids
```
Format:
```text
watchdog|BEC|12345
app|BEC|12346
```
The main game server watchdog PID is not stored in this file.
## Lifecycle
On server start, the agent:
1. Creates `_gsp_content/hooks`, `_gsp_content/generated`, and `_gsp_content/runtime`.
2. Reads enabled hook manifests matching the agent platform.
3. Generates platform-specific hook watchdog scripts.
4. Starts `before_server` hooks.
5. Starts the game server.
6. Starts `after_server` hooks.
7. Cleans up hook watchdogs and apps when the game server exits.
On Panel Stop or Restart, agents kill hook watchdog PIDs first and hook app PIDs
second, then continue normal game process and screen/session cleanup.
## Legacy `_alsoRun.bat`
Windows `_alsoRun.bat` support remains for compatibility, but it is deprecated.
New companion applications should be installed as `Server-side Application`
content with hook metadata so both Linux and Windows agents can manage them through the same hook
contract.
## Examples
Ordinary mod install:
- Category: `Mod`
- Install script handles download/extract/move
- No startup hook metadata
BEC install:
- Category: `Server-side Application`
- Install script places BEC files in the required folder
- Startup hook metadata writes `_gsp_content/hooks/bec.json`
Config install:
- Category: `Config`
- Install script writes or patches config files
- No special install mechanism beyond the scripted installer