Skip to content

Commit

Permalink
Enhance deployment workflow port management and Git handling
Browse files Browse the repository at this point in the history
- Improve port termination using `lsof` and `kill` for more robust process management
- Add Git reset to handle potential merge conflicts during deployment
- Streamline deployment script with clearer, more concise commands
  • Loading branch information
NagiPragalathan committed Feb 9, 2025
1 parent 036d321 commit b77e399
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,29 @@ jobs:
cd /var/www/Community_Management # Navigate to your Django project directory
echo "Starting deployment..."
# Kill any process using port 80 (development server port)
fuser -k 80/tcp || true # Ignore error if port isn't in use
# Kill any process using port 80
sudo lsof -i :80 | awk 'NR>1 {print $2}' | xargs sudo kill -9 || true
echo "Killed any processes using port 80"
# Set up virtual environment
# Ensure virtual environment is set up
python3 -m venv venv
source venv/bin/activate # Activate virtual environment
# Pull the latest code from GitHub
# Handle Git conflicts
git reset --hard HEAD
git pull origin main
echo "Pulled latest code from GitHub"
# Install the dependencies from the updated code
pip install -r requirements.txt
# Run database migrations
python manage.py migrate
echo "Ran database migrations"
# Run the Django development server in the background (not recommended for production)
nohup python manage.py runserver 0.0.0.0:80 > server.log 2>&1 &
echo "Started Django development server"
EOF

0 comments on commit b77e399

Please sign in to comment.