Skip to content

Commit

Permalink
Crash notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Wirewraith committed Feb 11, 2025
1 parent 767bf9f commit cccba5a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/server/crash-alert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

source /ss13_server/.env.build

errorlog="/ss13_server/data/errors.log"
url="$DISCORD_BOT_URL/server_crash"
api_key="$DISCORD_BOT_CRASH_KEY"
reason=$(tac "$errorlog" | sed -r '0,/BUG: Crashing/ d; /^\s*$/ { q }' | sed '/^$/d' | tac | jq -Rsa .)

echo "Sending crash alert to Discord"
curl -s -X POST -H "Content-Type: application/json" \
-d '{"api_key":"'"$api_key"'","server":"'"$SS13_ID"'","reason":'"$reason"'}' "$url"
7 changes: 7 additions & 0 deletions tools/server/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ export LD_LIBRARY_PATH=$BYONDDIR/bin${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}

echo "Starting server..."
DreamDaemon "goonstation.dmb" $SS13_PORT -trusted -verbose 2>&1 | bash tools/server/log.sh >> data/errors.log

exitCode=${PIPESTATUS[0]}
if [ $exitCode -ne 0 ]; then
echo "Crash detected!"
bash tools/server/crash-alert.sh
fi
exit $exitCode

0 comments on commit cccba5a

Please sign in to comment.