Vai al contenuto

SafeOps Production Setup

1) Prerequisiti

Assicurati che .env contenga almeno:

DB_AUTO_CREATE=false
DATABASE_URL=mysql+pymysql://...
REDIS_URL=redis://127.0.0.1:6379/1
CELERY_BROKER_URL=${REDIS_URL}
CELERY_RESULT_BACKEND=${REDIS_URL}
OPS_DAILY_CHECKS_ENABLED=true
OPS_DAILY_CHECKS_HOUR=7
OPS_DAILY_CHECKS_MINUTE=30

2) Systemd units

File template disponibili:

  • deploy/systemd/safeops-web.service
  • deploy/systemd/safeops-celery.service
  • deploy/systemd/safeops-celery-beat.service
  • deploy/systemd/safeops-print-engine.service

Installazione:

cp deploy/systemd/safeops-web.service /etc/systemd/system/
cp deploy/systemd/safeops-celery.service /etc/systemd/system/
cp deploy/systemd/safeops-celery-beat.service /etc/systemd/system/
cp deploy/systemd/safeops-print-engine.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now safeops-web.service
systemctl enable --now safeops-celery.service
systemctl enable --now safeops-celery-beat.service
systemctl enable --now safeops-print-engine.service

Log utili:

journalctl -u safeops-web.service -f
journalctl -u safeops-celery.service -f
journalctl -u safeops-celery-beat.service -f
journalctl -u safeops-print-engine.service -f

3) Nginx reverse proxy

Template:

  • deploy/nginx/safeops.conf.example

Installazione:

cp deploy/nginx/safeops.conf.example /etc/nginx/conf.d/safeops.conf
nginx -t
systemctl reload nginx

4) Validazioni rapide

flask --app app db current
flask --app app celery_ping --timeout 10
curl -sS http://127.0.0.1:18081/new/health

5) Rollback rapido

Per emergenza:

systemctl restart safeops-web.service
systemctl restart safeops-celery.service
systemctl restart safeops-celery-beat.service