Server hold / hibernate runbook
Server hold / hibernate runbook
This runbook pauses Cornice without dropping the database schema.
Use it when the project is on hold and you want to reclaim server CPU, memory, and disk while preserving:
- database schema
- users
- user profiles
- encrypted user secrets
- opportunity and market catalogs
- arb monitor profiles and arb opportunity catalog
What hibernate means here
Hibernate does not suspend the machine. It means:
- stop Cornice services
- clear high-volume runtime data
- optionally restart only the API in a dormant mode
The dormant mode is controlled by:
HIBERNATE_MODE=true
INGEST_ENABLED=false
With those set, the API can still come up, but it skips background loops.
Services involved
These are the relevant systemd units:
cornice.service— API / FastAPI processcornice-monitor.service— separate monitor process
These are not Celery units. If you have RabbitMQ or Celery on the server for some other project, they are outside this runbook unless you explicitly want to stop them too.
One-command hibernate
Run:
./scripts/hibernate_server.sh
That script:
-
writes these flags into the active env file:
HIBERNATE_MODE=true INGEST_ENABLED=false -
stops
cornice -
stops
cornice-monitorif present -
disables both services so they do not restart on reboot
-
truncates runtime tables with
scripts/clear_runtime_data.py
By default, the script looks for the env file in this order:
CORNICE_ENV_FILEif set- repo-local
.env /var/www/cornice/.env
If your server uses a different env file path, run:
CORNICE_ENV_FILE=/path/to/.env ./scripts/hibernate_server.sh
By default, it preserves:
usersuser_profilesuser_secretsopportunitiesglobal_marketsmarketsmarket_linksarb_monitor_profilesarb_opportunity_instancesarb_opportunity_legs
It clears runtime-heavy tables such as:
- market snapshots
- orderbook snapshots
- simulator runs/trades
- execution logs
- agent runs/findings
- requests
- arb observations
- arb GO signals
State after hibernate
After hibernate:
- the env file is set to dormant mode
corniceis stopped and disabledcornice-monitoris stopped and disabled
So you can leave the server alone without background work restarting.
Resume
When the project is active again:
- remove or change:
HIBERNATE_MODE=true
INGEST_ENABLED=false
- start services:
./scripts/resume_server.sh
That script starts:
cornicecornice-monitorif the unit exists- and re-enables both services
Notes on data loss
Hibernate clears runtime data only. The schema stays intact.
You will lose historical runtime rows from the cleared tables. That is intentional for reclaiming space.
You will keep:
- account access
- encrypted exchange secrets
- the opportunity catalog
If you want an even deeper wipe
The helper script supports additional flags:
python3 scripts/clear_runtime_data.py --include-opportunities
python3 scripts/clear_runtime_data.py --include-opportunities --include-auth
Do not use --include-auth unless you want to remove users, profiles, and secrets too.