Skip to content

Commit

Permalink
add graceful gunicorn restart to testnet after install script
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlanglen committed Jul 8, 2024
1 parent c0008b3 commit ecd1ebe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 0 additions & 6 deletions scripts/after_install_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,8 @@ if [ "$PENDING_MIGRATIONS" -gt 0 ]; then

echo 'Applying migrations...' >> "$LOG_FILE"
poetry run python manage.py migrate >> "$LOG_FILE" 2>&1

# echo 'Starting services...' >> "$LOG_FILE"
# sudo systemctl start gunicorn-dev celery-indexer-worker-dev celery-beat-worker-dev celery-beat-dev
else
# echo 'No migrations found. Running collectstatic and restarting services...' >> "$LOG_FILE"
echo 'No migrations found.' >> "$LOG_FILE"
# poetry run python manage.py collectstatic --noinput >> "$LOG_FILE" 2>&1
# sudo systemctl restart gunicorn-dev celery-indexer-worker-dev celery-beat-worker-dev celery-beat-dev
fi

# Collect static
Expand Down
18 changes: 12 additions & 6 deletions scripts/after_install_testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,19 @@ if [ "$PENDING_MIGRATIONS" -gt 0 ]; then

echo 'Applying migrations...' >> "$LOG_FILE"
poetry run python manage.py migrate >> "$LOG_FILE" 2>&1

echo 'Starting services...' >> "$LOG_FILE"
sudo systemctl start gunicorn-testnet celery-indexer-worker-testnet celery-beat-worker-testnet celery-beat-testnet
else
echo 'No migrations found. Running collectstatic and restarting services...' >> "$LOG_FILE"
poetry run python manage.py collectstatic --noinput >> "$LOG_FILE" 2>&1
sudo systemctl restart gunicorn-testnet celery-indexer-worker-testnet celery-beat-worker-testnet celery-beat-testnet
echo 'No migrations found.' >> "$LOG_FILE"
fi

# Collect static
echo 'Running collectstatic...' >> "$LOG_FILE"
poetry run python manage.py collectstatic --noinput >> "$LOG_FILE" 2>&1

# Gracefully reload Gunicorn to apply the changes without downtime
echo 'Reloading Gunicorn...' >> "$LOG_FILE"
sudo systemctl kill --signal=HUP gunicorn-testnet

echo 'Restarting services...' >> "$LOG_FILE"
sudo systemctl restart celery-indexer-worker-testnet celery-beat-worker-testnet celery-beat-testnet

echo "$(date '+%Y-%m-%d %H:%M:%S') - after_install_testnet.sh completed" >> "$LOG_FILE"

0 comments on commit ecd1ebe

Please sign in to comment.