A forge binary started as forge-runner acts as the runner, so a standalone runner that auto-updated to the forge binary keeps running under its old service line instead of exiting with the usage text
Browse files at this commitf4a7add41e943d8d12ee8f9e6e9335dab6847c89Parent: 9dc61f0- fix
- a forge binary started as forge-runner acts as the runner, so a standalone runner that auto-updated to the forge binary keeps running under its old service line instead of exiting with the usage text
1 changed file +12 -0
- crates/forge-web/src/main.rs +12 -0
crates/forge-web/src/main.rsmodified+12 -0
| @@ -87,6 +87,15 @@ async fn serve(config_path: &std::path::Path) -> Result<(), BoxError> { | |||
| 87 | Ok(()) | 87 | Ok(()) |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | +/// Whether the binary was started as `forge-runner`, which a runner's auto-update leaves in place | ||
| 91 | +/// of the standalone runner binary. | ||
| 92 | +fn invoked_as_runner() -> bool { | ||
| 93 | + std::env::args_os() | ||
| 94 | + .next() | ||
| 95 | + .map(std::path::PathBuf::from) | ||
| 96 | + .is_some_and(|path| path.file_name().is_some_and(|name| name == "forge-runner")) | ||
| 97 | +} | ||
| 98 | + | ||
| 90 | /// Splits the raw args into the config path, the `--admin` flag and the positional words. | 99 | /// Splits the raw args into the config path, the `--admin` flag and the positional words. |
| 91 | fn parse_args( | 100 | fn parse_args( |
| 92 | args: impl Iterator<Item = String>, | 101 | args: impl Iterator<Item = String>, |
| @@ -164,6 +173,9 @@ fn main() -> ExitCode { | |||
| 164 | // `runner` runs before the forge config is parsed, because its `--config` means the runner | 173 | // `runner` runs before the forge config is parsed, because its `--config` means the runner |
| 165 | // config, not the forge config. | 174 | // config, not the forge config. |
| 166 | let raw: Vec<std::ffi::OsString> = std::env::args_os().skip(1).collect(); | 175 | let raw: Vec<std::ffi::OsString> = std::env::args_os().skip(1).collect(); |
| 176 | + if invoked_as_runner() { | ||
| 177 | + return forge_runner::cli::main_with_args("forge-runner", raw.into_iter()); | ||
| 178 | + } | ||
| 167 | if raw.first().is_some_and(|arg| arg == "runner") { | 179 | if raw.first().is_some_and(|arg| arg == "runner") { |
| 168 | return forge_runner::cli::main_with_args("forge runner", raw.into_iter().skip(1)); | 180 | return forge_runner::cli::main_with_args("forge runner", raw.into_iter().skip(1)); |
| 169 | } | 181 | } |