Skip to content

Add signal/crash handling to the miner CLI #4826

Description

@JSONbored

Problem: No process-level signal handling exists anywhere in the miner package — no SIGINT/SIGTERM/uncaughtException/unhandledRejection handlers. The CLI dispatches through a chain of bare process.exit() calls with no cleanup hook, so an interrupted run leaves whatever state it was mid-writing in an undefined condition.

Area: AMS / CLI

Proposal: Add top-level signal and error handlers to the CLI entrypoint that flush/close any open ledger connections and exit cleanly, rather than letting the process die mid-write.

Deliverables:

  • Signal handlers registered once at CLI startup, covering every subcommand.
  • A defined, tested "safe exit" behavior for each ledger.

Acceptance criteria:

  • Sending SIGINT/SIGTERM mid-run leaves every ledger in a valid, non-corrupt state.
  • An uncaught exception is logged and exits with a non-zero code rather than crashing silently.

Resources:

  • The miner CLI's main entrypoint and dispatch chain.

Boundaries:

  • Handle cleanup only — don't change any command's actual business logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions