Skip to content

Commit

Permalink
teardown screen
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Schöchlin <[email protected]>
  • Loading branch information
scoopex committed Dec 4, 2024
1 parent 6856bbd commit 4ae12f1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn establish_screen_session(args: &CommandLineArgs){
.args(["-t", "init", "-S", &*args.inscreen, "-d", "-m", "sleep", "120"])
.output()
.expect("failed to start base screen");
output(format!("Wait for screen session for {} seconds", num), OutputType::Error);
output(format!("Wait for screen session for {} seconds", num), OutputType::Info);
thread::sleep(Duration::from_secs(1));
},
1 => {
Expand Down Expand Up @@ -89,8 +89,6 @@ fn establish_base_command(args: &CommandLineArgs, base_executable: &str, node: &
if COUNTER.fetch_add(1, Ordering::Relaxed) == 0 {
establish_screen_session(args);
}
output(format!("NOTE: command were execute in a screen session, attach by executing 'screen -x {}'", args.inscreen), OutputType::Info);
output_str("(see 'man screen' or 'STRG + a :help' for getting information about handling screen sessions)", OutputType::Info);

cmd = Command::new("screen");
cmd.args(["-x", &*args.inscreen, "-m", "-X", "screen", "-t", node]);
Expand Down Expand Up @@ -185,7 +183,6 @@ fn execute_remote(node: String, templated_lines: Vec<String>, args: &CommandLine
}

output(format!("Execute remote : {:?}", cmd), OutputType::Detail);
//output(format!("Execute remote : {:?}", cmd.to_string()), OutputType::Detail);
if args.term {
cmd.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
Expand Down Expand Up @@ -346,6 +343,18 @@ pub fn execute_nodes(nodes: Vec<String>, only_nodes: bool, execute_local: bool,
}
}

if args.inscreen != "" {
output_str("NOTE: Teardown 'init' screen now", OutputType::Detail);
Command::new("screen")
.args(["-x", &*args.inscreen,"-p","init", "-X","kill"])
.output()
.expect("Failed to teadown 'init' screen");

output(format!("NOTE: command were executed in a screen session, attach to the screen session by executing 'screen -x {}'", args.inscreen), OutputType::Info);
output_str("(see 'man screen' or 'STRG + a :help' for getting information about handling screen sessions)", OutputType::Info);

}

failed_nodes.sort();
failed_nodes.dedup();

Expand Down

0 comments on commit 4ae12f1

Please sign in to comment.