Skip to content

Commit

Permalink
add docker compose script
Browse files Browse the repository at this point in the history
Signed-off-by: sami <[email protected]>
  • Loading branch information
samiulsami committed Oct 25, 2024
1 parent f4e5db3 commit 551df10
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions server/apps/distributed-app/start_docker_compose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# To add this script as a cronjob,run 'crontab -e' and add the following line with the appropriate paths
# @reboot /path/to/directory/start_docker_compose.sh /path/to/directory >> /path/to/save/log/cronlog.log 2>&1

if [ $# -ne 1 ]; then
echo "Usage: $0 <directory>"
exit 1
fi

TARGET_DIR="$1"

while ! systemctl is-active --quiet docker; do
sleep 1
done

cd "$TARGET_DIR" || exit

while ! systemctl is-active --quiet docker; do
sleep 1
done

/usr/bin/docker compose -f docker-composeOLD.yml down
/usr/bin/docker compose -f docker-composeOLD.yml up -d

check_health() {
while true; do
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/healthcheck)
if [[ "$response" -eq 200 ]]; then
echo "Health check passed: Received 200 response."
break
else
echo "Health check failed: Received $response response. Retrying..."
sleep 5
fi
done
}

check_health

/usr/bin/docker exec james james-cli AddDomain cloud.appscode.com
/usr/bin/docker exec james james-cli AddUser [email protected] password

0 comments on commit 551df10

Please sign in to comment.