Skip to content

Commit

Permalink
Merge branch 'dev' into testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlanglen committed Jun 4, 2024
2 parents 65bb172 + 0bf1a26 commit bcf01ab
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 78 deletions.
7 changes: 5 additions & 2 deletions appspec-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/django-indexer
destination: /home/ec2-user/django-indexer-dev
hooks:
# # Install:
# BeforeInstall:
# - location: scripts/clean_destination_dev.sh
# timeout: 300
# runas: ec2-user
AfterInstall:
- location: scripts/after_install_dev.sh
timeout: 300
Expand Down
4 changes: 4 additions & 0 deletions appspec-testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ files:
destination: /home/ec2-user/django-indexer-testnet
hooks:
# # Install:
# BeforeInstall:
# - location: scripts/clean_destination_testnet.sh
# timeout: 300
# runas: ec2-user
AfterInstall:
- location: scripts/after_install_testnet.sh
timeout: 300
Expand Down
76 changes: 0 additions & 76 deletions scripts/after_install_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ echo "=========================================" >> "$LOG_FILE"
export PL_ENVIRONMENT=dev
source /home/ec2-user/.bashrc

echo "PL_ENVIRONMENT: $PL_ENVIRONMENT" >> "$LOG_FILE"
echo "PL_POSTGRES_HOST: $PL_POSTGRES_HOST" >> "$LOG_FILE"

# Set correct ownership recursively for project directory
sudo chown -R ec2-user:nginx /home/ec2-user/django-indexer-dev/
echo "$(date '+%Y-%m-%d %H:%M:%S') - Corrected ownership to ec2-user:nginx" >> "$LOG_FILE"
Expand Down Expand Up @@ -68,76 +65,3 @@ else
fi

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




# #!/bin/bash
# # Log output to a specific file
# LOG_FILE="/home/ec2-user/django-indexer-dev/logs/deploy.log"

# # print placeholder
# echo -e "\n THIS IS A PLACEHOLDER \n" >> "$LOG_FILE"

# echo -e "\n\n" >> "$LOG_FILE"
# echo "=========================================" >> "$LOG_FILE"
# echo "Running after_install_dev.sh at $(date '+%Y-%m-%d %H:%M:%S')" >> "$LOG_FILE"
# echo "=========================================" >> "$LOG_FILE"

# # Load env vars
# source /home/ec2-user/.bashrc

# # Set correct ownership recursively for project directory
# sudo chown -R ec2-user:nginx /home/ec2-user/django-indexer/
# echo "$(date '+%Y-%m-%d %H:%M:%S') - Corrected ownership to ec2-user:nginx" >> "$LOG_FILE"

# # Set the necessary permissions
# sudo chmod -R 775 /home/ec2-user/django-indexer/
# echo "$(date '+%Y-%m-%d %H:%M:%S') - Set permissions to 775" >> "$LOG_FILE"

# # Restart nginx to apply any configuration changes
# sudo systemctl restart nginx
# echo "$(date '+%Y-%m-%d %H:%M:%S') - Restarted nginx" >> "$LOG_FILE"

# # Define the project directory
# PROJECT_DIR="/home/ec2-user/django-indexer"

# # Navigate to the project directory
# cd "$PROJECT_DIR"

# # Source the specific poetry virtual environment
# source "/home/ec2-user/.cache/pypoetry/virtualenvs/django-indexer-Y-SQFfhb-py3.11/bin/activate" # TODO: UPDATE THIS

# # Install dependencies using Poetry
# echo "$(date '+%Y-%m-%d %H:%M:%S') - Installing dependencies with Poetry" >> "$LOG_FILE"
# poetry install >> "$LOG_FILE"
# echo "$(date '+%Y-%m-%d %H:%M:%S') - Dependencies installed" >> "$LOG_FILE"

# # Check if there are pending migrations and log the output
# echo "Checking for pending migrations..." >> "$LOG_FILE"
# PENDING_MIGRATIONS=$(poetry run python manage.py showmigrations | grep '\[ \]' 2>&1) # Redirect stderr to stdout
# echo "Migration check output: $PENDING_MIGRATIONS" >> "$LOG_FILE"

# # Log the full output of showmigrations
# echo "Checking for pending migrations..." >> "$LOG_FILE"
# poetry run python manage.py showmigrations >> "$LOG_FILE" 2>&1 # Logging full output to diagnose

# # Check for unapplied migrations
# PENDING_MIGRATIONS=$(poetry run python manage.py showmigrations | grep "\[ \]" | wc -l) # Count unapplied migrations

# if [ "$PENDING_MIGRATIONS" -gt 0 ]; then
# echo "Migrations found; stopping services..." >> "$LOG_FILE"
# sudo systemctl stop gunicorn celery-indexer-worker celery-beat-worker celery-beat

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

# echo 'Starting services...' >> "$LOG_FILE"
# sudo systemctl start gunicorn celery-indexer-worker celery-beat-worker celery-beat
# 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 celery-indexer-worker celery-beat-worker celery-beat
# fi

# echo "$(date '+%Y-%m-%d %H:%M:%S') - after_install_dev.sh completed" >> "$LOG_FILE"
8 changes: 8 additions & 0 deletions scripts/clean_destination_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Directory to clean
DEST_DIR="/home/ec2-user/django-indexer-dev"

# Delete all contents of the destination directory
if [ -d "$DEST_DIR" ]; then
rm -rf "${DEST_DIR:?}/*"
fi
8 changes: 8 additions & 0 deletions scripts/clean_destination_testnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Directory to clean
DEST_DIR="/home/ec2-user/django-indexer-testnet"

# Delete all contents of the destination directory
if [ -d "$DEST_DIR" ]; then
rm -rf "${DEST_DIR:?}/*"
fi

0 comments on commit bcf01ab

Please sign in to comment.