Webhooks
webhook.yml on the backends and the proxy: messages when a server drains, is empty or stops.
Both the backend plugin and the Velocity plugin read a file named webhook.yml. Each posts to a webhook URL, for example a Discord channel, so you know when a restart is safe.
| Where | File |
|---|---|
| Backend | plugins/MineDuels/webhook.yml |
| Proxy | plugins/mineduels/webhook.yml |
Each file is written with defaults on the first start. enabled is false until you turn it on.
Backend webhook.yml
config-version: 1
enabled: true
url: "https://discord.com/api/webhooks/123456789/abcdef"
format: discord
username: "MineDuels"
avatar-url: ""
mention: "<@&123456789012345678>"
server-label: ""
stable-seconds: 15
progress-minutes: 0
timeout-seconds: 5
retries: 2
events:
drain-started: true
drain-cancelled: true
drain-progress: true
drain-empty: true
server-started: true
server-stopping: true| Key | Default | Meaning |
|---|---|---|
enabled | false | Turns webhooks on. |
url | empty | An https address. Webhooks stay off with a warning when it is empty or not https. |
format | discord | discord sends an embed. json sends plain JSON for your own tools. |
username, avatar-url | MineDuels, empty | Sender name and picture in Discord. |
mention | empty | Pinged on every message. Only role and user pings such as <@&123> or <@456> are allowed. |
server-label | empty | The name in the message. Empty uses cross-server.server-name, or server on a standalone server. |
stable-seconds | 15 | The server must stay empty this long before drain-empty is sent. Range 1 to 600. |
progress-minutes | 0 | While draining and not yet empty, post the remaining players every this many minutes. 0 is off. |
timeout-seconds | 5 | Time allowed for one request. Range 1 to 30. |
retries | 2 | Tries after a failure. Range 0 to 5. |
events.<name> | true | false turns one message off. |
Backend events
| Event | Sent when |
|---|---|
drain-started | /md drain start. Lists players, running matches and pending assignments. |
drain-cancelled | /md drain stop. |
drain-progress | Every progress-minutes while draining and not empty. |
drain-empty | No players, no running matches and no pending assignments for stable-seconds. Once per drain. |
server-started | The plugin finished starting. |
server-stopping | The server is stopping. Sent before the plugin closes, waiting at most 3 seconds. |
Proxy webhook.yml
config-version: 1
enabled: true
url: "https://discord.com/api/webhooks/123456789/abcdef"
format: discord
username: "MineDuels Proxy"
mention: ""
server-label: "proxy-eu"
stable-seconds: 15
events:
proxy-drain-started: true
proxy-drain-cancelled: true
proxy-empty: true
network-drained: true
backend-lost: true
backend-recovered: true
gate-redis-down: trueThe keys are the same as on the backend, without progress-minutes. An empty server-label uses proxy-name.
Proxy events
| Event | Sent when |
|---|---|
proxy-drain-started | /mdproxy drain start. |
proxy-drain-cancelled | /mdproxy drain stop. |
proxy-empty | A draining proxy has no connected players for stable-seconds. |
network-drained | Every draining backend has no players and no running matches for stable-seconds. |
backend-lost | A backend stopped sending heartbeats. Not sent for a backend that was draining. |
backend-recovered | That backend sends heartbeats again. |
gate-redis-down | The proxy hears nothing from Redis. The gate then follows gate.on-redis-down. |
The backends report their own empty state and the proxy does not repeat it, so one restart gives one drain-empty.
Reload
| Where | Command |
|---|---|
| Backend | /md reload reads webhook.yml again. A broken file keeps the previous settings. |
| Proxy | /mdproxy reload |
Examples
Discord with a role ping
enabled: true
url: "https://discord.com/api/webhooks/123456789/abcdef"
format: discord
mention: "<@&123456789012345678>"The message title is game-2: Empty, safe to restart and the role is pinged.
Only the messages you want
events:
drain-started: false
drain-cancelled: false
drain-progress: false
drain-empty: true
server-started: false
server-stopping: falseProgress every 5 minutes on a busy server
progress-minutes: 5
stable-seconds: 30JSON for your own tools
format: json
url: "https://hooks.example.com/mineduels"Each message is one POST with this body:
{
"event": "drain-empty",
"server": "game-2",
"title": "Empty, safe to restart",
"detail": "No players, running matches or pending assignments for 15s.",
"time": "2026-11-22T21:40:12.318Z"
}Restart the server when it is empty
A small receiver that restarts a Pterodactyl server on drain-empty. format is json:
from http.server import BaseHTTPRequestHandler, HTTPServer
import json, urllib.request
SERVERS = {"game-2": "a01a22ef"}
PANEL = "https://panel.example.com"
KEY = "ptlc_your_client_api_key"
class Hook(BaseHTTPRequestHandler):
def do_POST(self):
body = json.loads(self.rfile.read(int(self.headers["Content-Length"])))
self.send_response(204)
self.end_headers()
if body["event"] != "drain-empty" or body["server"] not in SERVERS:
return
req = urllib.request.Request(
f"{PANEL}/api/client/servers/{SERVERS[body['server']]}/power",
data=json.dumps({"signal": "restart"}).encode(),
headers={"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"},
)
urllib.request.urlopen(req)
HTTPServer(("0.0.0.0", 8080), Hook).serve_forever()Behaviour
| Thing | Behaviour |
|---|---|
| Where requests run | On their own thread. A slow or broken webhook never slows the game. |
| Queue | Up to 50 messages wait. The oldest are dropped first. |
| Retries | A failed request is retried with a growing delay. Discord rate limit answers (429) are honoured, up to 10 seconds. |
| Errors | Logged at most once a minute, with the host only. The URL is never logged. |
| Pings | Text from players or reasons cannot ping anyone. Only mention can. |