hive-forge: exit after HIVE_FORGE_DEADLINE instead of hanging on a stalled forge
forgejo-api 0.11.1's sync client builds its own reqwest client with no timeout and takes no caller-supplied client (sync.rs: new and with_user_agent are the only constructors), so a forge that accepts a connection and then stalls blocked every typed verb forever. A watchdog thread now starts before the client is built. After HIVE_FORGE_DEADLINE seconds (default 900, five minutes above DOWNLOAD_TIMEOUT) it prints a hive-forge: FAILED: line and exits 75. It bounds the whole command, not each request, and a write may already have landed when it fires; the help text and docs/tools/forge.md say so.
This commit is contained in:
parent
e7a46d9728
commit
ccc6993703
7 changed files with 192 additions and 2 deletions
|
|
@ -3,6 +3,8 @@
|
|||
//!
|
||||
//! `HIVE_FORGE_URL` — base URL, e.g. `http://localhost:3000`
|
||||
//! `HYPERHIVE_STATE_DIR` — state dir; `forge-token` lives here
|
||||
//! `HIVE_FORGE_DEADLINE` — optional; whole seconds one invocation may run
|
||||
//! before it exits with code 75 (default 900)
|
||||
//!
|
||||
//! The active repo resolves `-r/--repo` > the `origin` remote of the
|
||||
//! cwd's git checkout > `HIVE_FORGE_REPO` (last-resort override, unset
|
||||
|
|
@ -26,6 +28,7 @@
|
|||
|
||||
mod body;
|
||||
mod client;
|
||||
mod deadline;
|
||||
mod notify;
|
||||
mod verbs;
|
||||
|
||||
|
|
@ -37,6 +40,9 @@ use std::process::ExitCode;
|
|||
#[command(
|
||||
name = "hive-forge",
|
||||
about = "Forgejo CLI wrapper for hyperhive",
|
||||
after_help = "Deadline: hive-forge stops after HIVE_FORGE_DEADLINE seconds (default 900), \
|
||||
prints `hive-forge: FAILED: ...` and exits 75. A write may already have \
|
||||
reached the forge, so check before retrying.",
|
||||
disable_help_subcommand = true
|
||||
)]
|
||||
struct Cli {
|
||||
|
|
@ -235,6 +241,7 @@ fn run() -> Result<()> {
|
|||
print!("{}", clap_markdown::help_markdown_custom::<Cli>(&options));
|
||||
return Ok(());
|
||||
}
|
||||
deadline::start()?;
|
||||
let client = client::Client::from_env(cli.repo, cli.json, cli.forge)
|
||||
.context("initialize forge client")?;
|
||||
// Attach the resolved repo to every verb's error uniformly here,
|
||||
|
|
|
|||
Loading…
Reference in a new issue