Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions terraform/update_worker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -e

HOST="$1"
if [[ -z "$HOST" ]]; then
echo "Usage: $0 <ec2-ip-address>"
exit 1
fi

SSH_TARGET="ubuntu@$HOST"

echo "==> Fetching secrets from Heroku..."
ENV_FILE=$(mktemp)
heroku config --app geoinsight --shell > "$ENV_FILE"

echo "==> Uploading env file to remote machine..."
scp "$ENV_FILE" "$SSH_TARGET:/home/ubuntu/geoinsight.prod.env"
rm "$ENV_FILE"

echo "==> Pulling changes..."
ssh "$SSH_TARGET" 'cd /home/ubuntu/geoinsight && git pull'

echo "==> Adding SOURCE_VERSION to env file..."
ssh "$SSH_TARGET" 'echo "SOURCE_VERSION=$(git -C /home/ubuntu/geoinsight rev-parse HEAD)" >> /home/ubuntu/geoinsight.prod.env'

echo "==> Restarting celery service..."
ssh "$SSH_TARGET" 'sudo systemctl restart celery'

echo "==> Done! Celery worker is restarted on $HOST"