huskies: merge 1144 story Gateway trampoline-restart: detached helper survives the gateway's own death
This commit is contained in:
@@ -35,6 +35,11 @@ pub(crate) struct CliArgs {
|
||||
/// `HUSKIES_BINARY_SOURCE` env var, then derives the URL from
|
||||
/// `HUSKIES_UPSTREAM_GATEWAY`.
|
||||
pub(crate) upgrade_source: Option<String>,
|
||||
/// Path to a trampoline job file (`--trampoline <path>`).
|
||||
///
|
||||
/// When set, the binary runs as a detached trampoline helper: it kills the
|
||||
/// old gateway, starts the new one, polls its health, and rolls back on failure.
|
||||
pub(crate) trampoline: Option<String>,
|
||||
}
|
||||
|
||||
/// Parse CLI arguments into `CliArgs`, or exit early for `--help` / `--version`.
|
||||
@@ -51,6 +56,7 @@ pub(crate) fn parse_cli_args(args: &[String]) -> Result<CliArgs, String> {
|
||||
let mut upstream_gateway: Option<String> = None;
|
||||
let mut upgrade = false;
|
||||
let mut upgrade_source: Option<String> = None;
|
||||
let mut trampoline: Option<String> = None;
|
||||
let mut i = 0;
|
||||
|
||||
while i < args.len() {
|
||||
@@ -143,6 +149,16 @@ pub(crate) fn parse_cli_args(args: &[String]) -> Result<CliArgs, String> {
|
||||
a if a.starts_with("--source=") => {
|
||||
upgrade_source = Some(a["--source=".len()..].to_string());
|
||||
}
|
||||
"--trampoline" => {
|
||||
i += 1;
|
||||
if i >= args.len() {
|
||||
return Err("--trampoline requires a path".to_string());
|
||||
}
|
||||
trampoline = Some(args[i].clone());
|
||||
}
|
||||
a if a.starts_with("--trampoline=") => {
|
||||
trampoline = Some(a["--trampoline=".len()..].to_string());
|
||||
}
|
||||
a if a.starts_with('-') => {
|
||||
return Err(format!("unknown option: {a}"));
|
||||
}
|
||||
@@ -172,6 +188,7 @@ pub(crate) fn parse_cli_args(args: &[String]) -> Result<CliArgs, String> {
|
||||
upstream_gateway,
|
||||
upgrade,
|
||||
upgrade_source,
|
||||
trampoline,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user