CoR-Forum / CoRT

Champions of Regnum trainer, war status, bosses respawn and bz countdown
https://cort.cor-forum.de/
GNU Affero General Public License v3.0
0 stars 0 forks source link

FIX: server crashing if mysql connection is lost #20

Open Joshua2504 opened 3 months ago

Joshua2504 commented 2 months ago

I implemented the following dirty script on server-side.

Let me know if you have any ideas...

crontab -e (replace <dir>)

*/1 * * * * <dir>/corforum/CoRT/check.sh 2>&1

check.sh (replace <dir>)

#!/bin/bash

# Define the URL to check
URL="https://cort.cor-forum.de"

# Send a GET request to the URL and capture the HTTP status code
HTTP_STATUS=$(curl -o /dev/null -s -w "%{http_code}\n" $URL)

# Check if the HTTP status code is 200
if [ "$HTTP_STATUS" -ne 200 ]; then
  echo "Site $URL is not reachable. Status code: $HTTP_STATUS"
  echo "Restarting Docker Compose services..."

  # Navigate to the Docker Compose directory
  cd <dir> /corforum/CoRT

  # Restart the Docker Compose services
  docker compose restart

  echo "Docker Compose services restarted."
else
  echo "Site $URL is reachable. Status code: $HTTP_STATUS"
fi