Staging safety
Scopo
Evitare effetti collaterali di staging su sistemi esterni (email, webhook, Business Cube).
Prerequisiti
- Stack staging up; file env
deploy/env/.env.staging(o equivalente Coolify). - Compose:
COMPOSE_FILE=deploy/compose/staging.yml(default script).
Procedura
bash
bash scripts/staging-safety.shLo script esegue sul site staging:
mute_emails = 1disable_external_webhooks = 1- svuota
business_cube_api_urlin site config clear-cache
Non modifica NODE_RED_* (il gateway OT di staging resta raggiungibile in rete privata; le scritture PLC restano off via OT_WRITES_ENABLED=0 sul compose Node-RED).
Variabili env
In deploy/env/.env.staging.example:
MUTE_EMAILS=1DISABLE_EXTERNAL_WEBHOOKS=1
Refresh da produzione
bash
PROD_BACKUP_ID=<timestamp> bash scripts/staging-refresh.shRestore backup prod su staging + scripts/anonymize-data.py (email utenti/anagrafiche) + safety.
Verifica
bash
# Sul backend staging
bench --site <SITE_NAME> get-config mute_emails
# atteso: 1Invio email di test non deve raggiungere destinatari reali.
Rollback / Troubleshooting
- Safety non applicata post-deploy: rieseguire lo script (non è sempre automatica in Actions).
- Dati sensibili dopo refresh: rieseguire
anonymize-data.pye estendere lo script se servono nuovi DocType. - Reset volumi: vietato su staging senza conferma esplicita.
