Skip to content

Commit 912782b

Browse files
authored
Merge pull request #290 from OpenGeoscience/update-worker-script
Add worker update script
2 parents f99fd9e + 7bbbc1b commit 912782b

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

terraform/update_worker.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
HOST="$1"
5+
if [[ -z "$HOST" ]]; then
6+
echo "Usage: $0 <ec2-ip-address>"
7+
exit 1
8+
fi
9+
10+
SSH_TARGET="ubuntu@$HOST"
11+
12+
echo "==> Fetching secrets from Heroku..."
13+
ENV_FILE=$(mktemp)
14+
heroku config --app geoinsight --shell > "$ENV_FILE"
15+
16+
echo "==> Uploading env file to remote machine..."
17+
scp "$ENV_FILE" "$SSH_TARGET:/home/ubuntu/geoinsight.prod.env"
18+
rm "$ENV_FILE"
19+
20+
echo "==> Pulling changes..."
21+
ssh "$SSH_TARGET" 'cd /home/ubuntu/geoinsight && git pull'
22+
23+
echo "==> Adding SOURCE_VERSION to env file..."
24+
ssh "$SSH_TARGET" 'echo "SOURCE_VERSION=$(git -C /home/ubuntu/geoinsight rev-parse HEAD)" >> /home/ubuntu/geoinsight.prod.env'
25+
26+
echo "==> Restarting celery service..."
27+
ssh "$SSH_TARGET" 'sudo systemctl restart celery'
28+
29+
echo "==> Done! Celery worker is restarted on $HOST"

0 commit comments

Comments
 (0)