/[Sack]/trunk/lib/Sack/Lorry.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Sack/Lorry.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 143 by dpavlin, Wed Oct 7 20:52:20 2009 UTC revision 144 by dpavlin, Wed Oct 7 20:55:14 2009 UTC
# Line 272  sub view { Line 272  sub view {
272          return $out;          return $out;
273  }  }
274    
275    sub update_node {
276            my $self = shift;
277            my $updated;
278            foreach my $port ( @_ ) {
279                    my $host = $self->{port_on_host}->{$port} || die "no port $port in ",dump $self;
280                    next if $host =~ m{(localhost|127\.)};
281                    next if $updated->{$host}++;
282                    warn "update $host $Sack::VERSION\n";
283                    system("find /srv/Sack/ | cpio --create | ssh -F etc/lib.ssh $host cpio --extract --make-directories --unconditional") == 0 and $self->restart_nodes( $port );
284            }
285    }
286    
287  sub command {  sub command {
288          my ( $self, $cmd ) = @_;          my ( $self, $cmd ) = @_;
289    
# Line 292  sub command { Line 304  sub command {
304          } elsif ( $cmd =~ m{^i} ) {          } elsif ( $cmd =~ m{^i} ) {
305                  $self->send_to_all({ info => 1 });                  $self->send_to_all({ info => 1 });
306                  my $info = $self->get_from_all;                  my $info = $self->get_from_all;
307                    warn "INFO view $self->{view} ", -s $self->{view}, " bytes\n";
308                  foreach my $port ( $self->connected ) {                  foreach my $port ( $self->connected ) {
309                          warn "INFO view $self->{view} ", -s $self->{view}, " bytes\n";                          warn "[$port] $self->{port_on_host}->{$port} $pids->{$port} ", dump( $info->{$port} ), "\n";
310                          warn "[$port] $self->{port_on_host}->{$port} ", dump( $info->{$port} ), "\n";                          if ( my $version = $info->{version} ) {
311                                    warn "# $version $Sack::VERSION\n";
312                                    $self->update_node( $port ) if $version ne $Sack::VERSION;
313                            }
314                  }                  }
315          } elsif ( $cmd =~ m{^u} ) {          } elsif ( $cmd =~ m{^u} ) {
316                  my $updated;                  $self->update_node( $self->connected );
                 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";  
                 }  
317          } elsif ( $cmd =~ m{^sh\s+(.+)} ) {          } elsif ( $cmd =~ m{^sh\s+(.+)} ) {
318                  $self->send_to_all({ sh => $1 });                  $self->send_to_all({ sh => $1 });
319                  my $sh = $self->get_from_all;                  my $sh = $self->get_from_all;

Legend:
Removed from v.143  
changed lines
  Added in v.144

  ViewVC Help
Powered by ViewVC 1.1.26