Every time you SSH into either server to do work, run these three commands:
cd /var/www/yealinbilling
source venv/bin/activate
export DJANGO_SETTINGS_MODULE=config.settings.development
cd /var/www/yealinbilling
source venv/bin/activate
export DJANGO_SETTINGS_MODULE=config.settings.production
cd /var/www/yealinbilling — moves to the project root where all management commands must be run from.
source venv/bin/activate — activates the Python virtual environment. The venv stays active for the entire terminal session until you close it or run deactivate. Without this, Python commands use the system Python which doesn't have the project's packages installed. You'll see (venv) in your prompt when active.
export DJANGO_SETTINGS_MODULE — tells Django which settings file to use. Without this, Django won't know if it's running in development or production mode and will error.
# Check all 6 services at once
sudo systemctl status gunicorn celery celerybeat nginx postgresql redis-server --no-pager | grep -E "Active:|●"
# Expected output (all should show "active (running)"):
# ● gunicorn.service — Active: active (running)
# ● celery.service — Active: active (running)
# ● celerybeat.service — Active: active (running)
# ● nginx.service — Active: active (running)
# ● postgresql.service — Active: active (exited) ← this is normal for PostgreSQL
# ● redis-server.service — Active: active (running)
# Restart all app services (after code changes)
sudo systemctl restart gunicorn celery celerybeat
# Restart just Gunicorn (most common — after .env changes)
sudo systemctl restart gunicorn
# Restart Nginx (after config changes)
sudo systemctl restart nginx
# Restart everything
sudo systemctl restart gunicorn celery celerybeat nginx
# Gunicorn application log (most useful)
sudo journalctl -u gunicorn -f
# Last 50 lines of Gunicorn log
sudo journalctl -u gunicorn -n 50 --no-pager
# Nginx error log
sudo tail -f /var/log/nginx/error.log
# Celery worker log
tail -f /var/www/yealinbilling/logs/celery-worker.log
# Celery beat log
tail -f /var/www/yealinbilling/logs/celery-beat.log
# All app logs
tail -f /var/www/yealinbilling/logs/*.log
echo "=== Services ===" && sudo systemctl is-active gunicorn celery celerybeat nginx postgresql redis-server
echo "=== Disk ===" && df -h /
echo "=== Memory ===" && free -h
echo "=== Docker (Wiki.js) ===" && docker ps --format "table {{.Names}}\t{{.Status}}"
cd /var/www/yealinbilling
source venv/bin/activate
export DJANGO_SETTINGS_MODULE=config.settings.development
# Make changes, test them, then:
cd frontend && npm run build
cd /var/www/yealinbilling
git add .
git commit -m "Description of changes"
git push origin main
ssh crip@51.161.136.89
cd /var/www/yealinbilling
source venv/bin/activate
export DJANGO_SETTINGS_MODULE=config.settings.production
git stash # stash any local changes
git pull origin main # pull latest from GitHub
git stash drop # drop stashed changes
python manage.py migrate # run any new migrations
python manage.py check # verify no issues
python manage.py collectstatic --noinput # collect static files
cd frontend && npm run build # rebuild React frontend
cd /var/www/yealinbilling
sudo systemctl restart gunicorn celery celerybeat