Home

/

Library

/

ops/hibernate.md

Hibernate / pause runbook

Hibernate / pause runbook

Use this when the project is on hold and you want to stop background work and reclaim disk without dropping the database schema.

For the full operational version, see docs/ops/server-hold-runbook.md.

Goal

  • stop Cornice background processing
  • preserve the database schema
  • optionally preserve users and encrypted secrets
  • free disk held by runtime tables

Recommended server steps

Fast path:

./scripts/hibernate_server.sh

That script:

  • writes HIBERNATE_MODE=true and INGEST_ENABLED=false into the env file
  • stops cornice
  • stops cornice-monitor if present
  • disables both services so they stay shelved
  • clears runtime tables while preserving users, profiles, secrets, market catalogs, and opportunity catalogs

Manual path:

  1. Stop services.

    If you run only the API service:

    sudo systemctl stop cornice
    

    If you also run a separate monitor service, stop that too:

    sudo systemctl stop cornice-monitor
    
  2. Put the API into hibernate mode before the next restart.

    In your server env file:

    HIBERNATE_MODE=true
    INGEST_ENABLED=false
    

    HIBERNATE_MODE=true keeps the FastAPI app available but skips all background tasks on startup.

  3. Clear runtime data.

    Preserve users, profiles, secrets, market catalogs, and opportunity catalogs:

    python3 scripts/clear_runtime_data.py
    

    Also clear the opportunities catalog:

    python3 scripts/clear_runtime_data.py --include-opportunities
    

    Fully empty all application tables, including auth/secrets:

    python3 scripts/clear_runtime_data.py --include-opportunities --include-auth
    
  4. If you still want the API up for login/inspection, restart only the API service:

    sudo systemctl start cornice
    

What the cleanup script removes by default

  • execution_orders
  • executions
  • simulator_trades
  • simulator_runs
  • agent_findings
  • agent_runs
  • opportunity_observations
  • hourly_prices
  • market_snapshots
  • orderbook_snapshots
  • requests
  • arb_go_signals
  • arb_observations

What it preserves by default

  • users
  • user_profiles
  • user_secrets
  • opportunities
  • global_markets
  • markets
  • market_links
  • arb_monitor_profiles
  • arb_opportunity_instances
  • arb_opportunity_legs

Notes

  • This does not drop tables or migrations.
  • TRUNCATE ... RESTART IDENTITY CASCADE is used so disk-heavy runtime tables are emptied cleanly.
  • If you want the smallest server footprint, keep both services stopped instead of restarting the API in hibernate mode.