mirror of
https://github.com/duncs/clusterssh.git
synced 2025-07-02 09:31:15 +00:00
Allow re-adding of previously closed sessions
Keep track of which sessions are closed and allow the user to re-add them in one go. Useful in environments with a lot of network problems.
This commit is contained in:
parent
f23821af6f
commit
576ace2e3d
1 changed files with 31 additions and 0 deletions
|
@ -111,6 +111,7 @@ my $sysconfigdir = "/etc";
|
|||
my %ssh_hostnames;
|
||||
my $host_menu_static_items; # number of items in the host menu that should
|
||||
# not be touched by build_host_menu
|
||||
my(@dead_hosts); # list of hosts whose sessions are now closed
|
||||
|
||||
$keysymtocode{unknown_sym} = 0xFFFFFF; # put in a default "unknown" entry
|
||||
$keysymtocode{EuroSign}
|
||||
|
@ -1233,6 +1234,31 @@ sub add_host_by_name() {
|
|||
}
|
||||
}
|
||||
|
||||
# attempt to re-add any hosts that have been closed since we started
|
||||
# the session - either through errors or deliberate log-outs
|
||||
sub re_add_closed_sessions() {
|
||||
my ($self) = @_;
|
||||
$self->debug( 2, "add closed sessions" );
|
||||
|
||||
return if (scalar(@dead_hosts) == 0);
|
||||
|
||||
my @new_hosts = @dead_hosts;
|
||||
# clear out the list in case open fails
|
||||
@dead_hosts = qw//;
|
||||
# try to open
|
||||
$self->open_client_windows(@new_hosts);
|
||||
# update hosts list with current state
|
||||
$self->build_hosts_menu();
|
||||
|
||||
# retile, or bring console to front
|
||||
if ( $self->config->{window_tiling} eq "yes" ) {
|
||||
return $self->retile_hosts();
|
||||
}
|
||||
else {
|
||||
return $self->show_console();
|
||||
}
|
||||
}
|
||||
|
||||
sub build_hosts_menu() {
|
||||
my ($self) = @_;
|
||||
$self->debug( 2, "Building hosts menu" );
|
||||
|
@ -1294,6 +1320,7 @@ sub setup_repeat() {
|
|||
if ( defined( $servers{$svr}{pid} ) ) {
|
||||
if ( !kill( 0, $servers{$svr}{pid} ) ) {
|
||||
$build_menu = 1;
|
||||
push(@dead_hosts, $servers{$svr}{givenname});
|
||||
delete( $servers{$svr} );
|
||||
$self->debug( 0, "$svr session closed" );
|
||||
}
|
||||
|
@ -1755,6 +1782,10 @@ sub create_menubar() {
|
|||
-command => sub { $self->add_host_by_name, },
|
||||
-accelerator => $self->config->{key_addhost},
|
||||
],
|
||||
[ "command",
|
||||
"Re-add closed session(s)",
|
||||
-command => sub { $self->re_add_closed_sessions() },
|
||||
],
|
||||
'' # this is needed as build_host_menu always drops the
|
||||
# last item
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue