Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: support setting the --parent-process-id in command shell #193735

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions cli/src/commands/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ pub struct CommandShellArgs {
/// Require the given token string to be given in the handshake.
#[clap(long)]
pub require_token: Option<String>,
/// Optional parent process id. If provided, the server will be stopped when the process of the given pid no longer exists
#[clap(long, hide = true)]
pub parent_process_id: Option<String>,
}

#[derive(Args, Debug, Clone)]
Expand Down
7 changes: 6 additions & 1 deletion cli/src/commands/tunnels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ impl ServiceContainer for TunnelServiceContainer {

pub async fn command_shell(ctx: CommandContext, args: CommandShellArgs) -> Result<i32, AnyError> {
let platform = PreReqChecker::new().verify().await?;
let mut shutdown_reqs = vec![ShutdownRequest::CtrlC];
if let Some(p) = args.parent_process_id.and_then(|p| Pid::from_str(&p).ok()) {
shutdown_reqs.push(ShutdownRequest::ParentProcessKilled(p));
}

let mut params = ServeStreamParams {
log: ctx.log,
launcher_paths: ctx.paths,
Expand All @@ -144,7 +149,7 @@ pub async fn command_shell(ctx: CommandContext, args: CommandShellArgs) -> Resul
.require_token
.map(AuthRequired::VSDAWithToken)
.unwrap_or(AuthRequired::VSDA),
exit_barrier: ShutdownRequest::create_rx([ShutdownRequest::CtrlC]),
exit_barrier: ShutdownRequest::create_rx(shutdown_reqs),
code_server_args: (&ctx.args).into(),
};

Expand Down