Skip to content

[PR #30] listen has no SIGTERM/SIGINT handler — Docker stop kills in-flight ops dirty #85

@obchain

Description

@obchain

PR: #30 (feat/05-clap-cli)
File: crates/charon-cli/src/main.rs
Lines: ~63-65

Problem:

Command::Listen => {
    info!("listen: not wired up yet — scanner arrives in Day 2");
}

No signal handler installed. tokio does not catch SIGTERM by default. docker stop sends SIGTERM then SIGKILL after 10s. Once scanner lands, any in-flight liquidation tx or open state file will be dropped mid-operation on every deploy or container restart.

Fix: Establish shutdown pattern now before scanner wiring:

Command::Listen => {
    tokio::select! {
        _ = run_listen(&config) => {},
        _ = tokio::signal::ctrl_c() => {
            info!("received SIGINT, shutting down");
        },
        _ = async {
            tokio::signal::unix::signal(
                tokio::signal::unix::SignalKind::terminate()
            ).unwrap().recv().await;
        } => {
            info!("received SIGTERM, shutting down");
        },
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    layer:rustRust crates (core / scanner / protocols / executor / cli)pr-reviewFindings from PR review processpriority:p1-coreCore MVP scope

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions