╔═══════════════════════════════════════════════════════════╗ ║ Church Music Database - Systemd Setup Complete ✓ ║ ╚═══════════════════════════════════════════════════════════╝ ✅ PRODUCTION DEPLOYMENT SUCCESSFUL Services Configured: • church-music-backend.service (Flask/Gunicorn on :8080) • church-music-frontend.service (React/serve on :5100) Status: RUNNING & AUTO-START ENABLED ┌─────────────────────────────────────────────────────────┐ │ 🔧 QUICK COMMANDS │ └─────────────────────────────────────────────────────────┘ Service Management: ./manage-services.sh status # Check service status ./manage-services.sh restart # Restart both services ./manage-services.sh stop # Stop services ./manage-services.sh start # Start services ./manage-services.sh health # Health check endpoints ./manage-services.sh logs # View backend logs (live) ./manage-services.sh logs-fe # View frontend logs (live) Direct systemd Commands: sudo systemctl status church-music-backend sudo systemctl restart church-music-backend sudo systemctl stop church-music-backend sudo systemctl start church-music-backend sudo journalctl -u church-music-backend -f sudo journalctl -u church-music-frontend -f ┌─────────────────────────────────────────────────────────┐ │ 🌐 ACCESS URLs │ └─────────────────────────────────────────────────────────┘ Frontend: http://localhost:5100 http://192.168.10.130:5100 Backend: http://localhost:8080/api/health http://192.168.10.130:8080/api/health ┌─────────────────────────────────────────────────────────┐ │ 📊 RESOURCE USAGE │ └─────────────────────────────────────────────────────────┘ Backend: ~90MB RAM | 2 workers | CPU: 50% quota Frontend: ~25MB RAM | 1 worker | CPU: 25% quota Total: ~115MB | Minimal when idle ┌─────────────────────────────────────────────────────────┐ │ 🔒 SECURITY FEATURES │ └─────────────────────────────────────────────────────────┘ ✓ Non-root user (pts) ✓ NoNewPrivileges enabled ✓ Private /tmp directory ✓ Resource limits configured ✓ Auto-restart on crash ✓ Separate log files ✓ Environment variables secured ✓ Production-grade WSGI server (Gunicorn) ┌─────────────────────────────────────────────────────────┐ │ 🚀 AUTO-START ON REBOOT │ └─────────────────────────────────────────────────────────┘ Status: ENABLED ✓ Both services will automatically start when the server reboots. They will also automatically restart if they crash. Test reboot behavior: sudo systemctl reboot ┌─────────────────────────────────────────────────────────┐ │ 📝 LOG FILES │ └─────────────────────────────────────────────────────────┘ Backend Application: /media/pts/Website/Church_HOP_MusicData/backend/logs/access.log /media/pts/Website/Church_HOP_MusicData/backend/logs/error.log /media/pts/Website/Church_HOP_MusicData/backend/logs/service.log /media/pts/Website/Church_HOP_MusicData/backend/logs/service-error.log Systemd Journal: sudo journalctl -u church-music-backend -n 100 sudo journalctl -u church-music-frontend -n 100 ┌─────────────────────────────────────────────────────────┐ │ 📁 KEY FILES │ └─────────────────────────────────────────────────────────┘ Service Files: /etc/systemd/system/church-music-backend.service /etc/systemd/system/church-music-frontend.service Configuration: /media/pts/Website/Church_HOP_MusicData/backend/.env.systemd /media/pts/Website/Church_HOP_MusicData/backend/gunicorn_config.py Scripts: /media/pts/Website/Church_HOP_MusicData/manage-services.sh /media/pts/Website/Church_HOP_MusicData/systemd-setup.sh Documentation: /media/pts/Website/Church_HOP_MusicData/SYSTEMD_PRODUCTION_GUIDE.md ┌─────────────────────────────────────────────────────────┐ │ 🔄 UPDATING THE APPLICATION │ └─────────────────────────────────────────────────────────┘ 1. Stop services: ./manage-services.sh stop 2. Update code: git pull # or update manually 3. Update backend dependencies (if needed): cd backend source venv/bin/activate pip install -r requirements.txt 4. Rebuild frontend: cd ../frontend npm run build 5. Start services: cd .. ./manage-services.sh start ┌─────────────────────────────────────────────────────────┐ │ ⚙️ TROUBLESHOOTING │ └─────────────────────────────────────────────────────────┘ Service won't start: sudo journalctl -u church-music-backend -n 50 sudo systemctl status church-music-backend -l Port already in use: sudo netstat -tulpn | grep 8080 sudo fuser -k 8080/tcp Database connection issues: Check PostgreSQL is running Verify credentials in .env.systemd Rebuild if needed: cd frontend && npm run build ┌─────────────────────────────────────────────────────────┐ │ ✅ PRODUCTION CHECKLIST │ └─────────────────────────────────────────────────────────┘ ✓ Backend runs on Gunicorn (production WSGI) ✓ Frontend served as static files (not dev server) ✓ Services run as non-root user ✓ Auto-restart on failure enabled ✓ Resource limits configured ✓ Security hardening applied ✓ Logs properly configured ✓ Environment variables secured ✓ Auto-start on boot enabled ✓ Health endpoints working ⚠️ Optional Enhancements: ☐ SSL/TLS certificate (nginx-ssl.conf available) ☐ Database migrations applied ☐ Firewall rules configured ☐ Regular backups scheduled ☐ Monitoring/alerting setup ═══════════════════════════════════════════════════════════ For detailed documentation, see: SYSTEMD_PRODUCTION_GUIDE.md Services are ready for production use! 🎉