--- trunk/lib/Sack/Lorry.pm 2009/10/07 20:52:20 143 +++ trunk/lib/Sack/Lorry.pm 2009/10/07 20:55:14 144 @@ -272,6 +272,18 @@ return $out; } +sub update_node { + my $self = shift; + my $updated; + foreach my $port ( @_ ) { + my $host = $self->{port_on_host}->{$port} || die "no port $port in ",dump $self; + next if $host =~ m{(localhost|127\.)}; + next if $updated->{$host}++; + warn "update $host $Sack::VERSION\n"; + system("find /srv/Sack/ | cpio --create | ssh -F etc/lib.ssh $host cpio --extract --make-directories --unconditional") == 0 and $self->restart_nodes( $port ); + } +} + sub command { my ( $self, $cmd ) = @_; @@ -292,17 +304,16 @@ } elsif ( $cmd =~ m{^i} ) { $self->send_to_all({ info => 1 }); my $info = $self->get_from_all; + warn "INFO view $self->{view} ", -s $self->{view}, " bytes\n"; foreach my $port ( $self->connected ) { - warn "INFO view $self->{view} ", -s $self->{view}, " bytes\n"; - warn "[$port] $self->{port_on_host}->{$port} ", dump( $info->{$port} ), "\n"; + warn "[$port] $self->{port_on_host}->{$port} $pids->{$port} ", dump( $info->{$port} ), "\n"; + if ( my $version = $info->{version} ) { + warn "# $version $Sack::VERSION\n"; + $self->update_node( $port ) if $version ne $Sack::VERSION; + } } } elsif ( $cmd =~ m{^u} ) { - my $updated; - foreach my $host ( $self->connected ) { - next if $updated->{$host}++; - warn "update $host\n"; - system "find /srv/Sack/ | cpio --create | ssh -F etc/lib.ssh $host cpio --extract --make-directories --unconditional"; - } + $self->update_node( $self->connected ); } elsif ( $cmd =~ m{^sh\s+(.+)} ) { $self->send_to_all({ sh => $1 }); my $sh = $self->get_from_all;