feature: webhook notify on systemd service start/stop

This commit is contained in:
a 2025-03-12 03:16:49 +00:00
parent 4533dd8d25
commit 02ebae1b6e
3 changed files with 13 additions and 0 deletions

View file

@ -22,6 +22,10 @@ Copy `.env.example` to `.env`:
- Settings > Advanced > Developer Mode: enabled
- Right click the guild and select "Copy ID"
- `DISCORD_STATUS_WEBHOOK_URL` (optional) is used to monitor when the bot fails
- Channel Settings > Integrations > New Webhook (don't forget to save changes)
- Copy Webhook URL
- `DISCORD_BOT_ADMIN_ROLE_ID` for reloading cogs
- `DISCORD_BOT_ADMIN_USER_ID` for reloading cogs
- `DISCORD_VCJOIN_CHANNEL` for the VCJoin cog

7
contrib/notify.sh Normal file
View file

@ -0,0 +1,7 @@
#!/usr/bin/bash
curl \
-X POST \
-H "Content-Type: application/json" \
-d '{"username": "system", "content": "'"$1"'"}' \
$DISCORD_STATUS_WEBHOOK_URL

View file

@ -8,6 +8,8 @@ User=discord
WorkingDirectory=/srv/discord/%I
EnvironmentFile=/srv/discord/%I/.env
ExecStart=/srv/discord/.venv/bin/python -u app.py
ExecStopPost=/srv/discord/%I/notify.sh "umi instance stopped: `%i`"
ExecStartPost=/srv/discord/%I/notify.sh "umi instance started: `%i`"
[Install]
WantedBy=multi-user.target