Production Deploy
Run both services under systemd so they start automatically on boot and restart on failure.
Run both services under systemd so they start automatically on boot and restart on failure.
Backend Service
Create /etc/systemd/system/pycon-backend.service:
[Unit]
Description=PyServer Manager Backend
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/pycon/backend
ExecStart=/opt/pycon/backend/venv/bin/uvicorn main:app --host 0.0.0.0 --port 8000
Restart=always
RestartSec=5
Environment=PYTHONUNBUFFERED=1
[Install]
WantedBy=multi-user.targetFrontend Service
Create /etc/systemd/system/pycon-frontend.service:
[Unit]
Description=PyServer Manager Frontend
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/pycon/frontend
ExecStart=/usr/bin/npm start
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.targetEnable & Start
sudo systemctl daemon-reload
sudo systemctl enable pycon-backend pycon-frontend
sudo systemctl start pycon-backend pycon-frontend
# Check status
sudo systemctl status pycon-backend
sudo systemctl status pycon-frontendUpdate Deployed Code
cd /opt/pycon && git pull origin main
# Rebuild frontend
cd /opt/pycon/frontend && npm run build
# Restart services
sudo systemctl restart pycon-backend pycon-frontend