Skip to content

ant-devnet: handle SIGTERM and use a per-run data dir by default #261

Open

Description

@Nic-dorman

Problem

ant-devnet still leaves state behind when it is stopped with SIGTERM, which is how process managers and ant dev stop stop it. This is the remainder of WithAutonomi/ant-sdk#73.

Already fixed on main: the Anvil Testnet is now kept alive until main exits (local_testnet: Option<evmlib::testnet::Testnet>) instead of std::mem::forget, so its Drop runs on a normal exit.

Still open in src/bin/ant-devnet/main.rs:

  1. Only SIGINT is handled. The binary waits on tokio::signal::ctrl_c(). On SIGTERM the process dies without calling devnet.shutdown(), so cleanup_data_dir is never honoured and the Anvil child is not dropped.
  2. The default data dir is shared across runs. DevnetConfig::default() uses default_root_dir() (~/.local/share/ant/ on Linux). An interrupted run leaves partial node identities there for the next run to trip over.

Proposed fix

  1. Wait on SIGINT or SIGTERM (tokio::signal::unix::signal(SignalKind::terminate()) on Unix, ctrl_c elsewhere) before calling devnet.shutdown().await.
  2. When --data-dir is not given, use a fresh per-run directory (tempfile::TempDir or temp_dir().join("ant_devnet_{rand}")). The manifest already records the paths, so consumers can still find them. This matches tests/e2e/testnet.rs and ant-core's MiniTestnet.

Once this lands, ant-sdk's ant dev stop band-aid (force-kill plus wiping ~/.local/share/ant/{nodes,spill}, from ant-sdk#81) can be reduced.

Background, bisect and repro: WithAutonomi/ant-sdk#73.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions