/[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 97 by dpavlin, Sun Oct 4 13:09:28 2009 UTC revision 107 by dpavlin, Mon Oct 5 22:21:39 2009 UTC
# Line 7  use IO::Socket::INET; Line 7  use IO::Socket::INET;
7  use Data::Dump qw(dump);  use Data::Dump qw(dump);
8  use Storable;  use Storable;
9  use File::Slurp;  use File::Slurp;
10    use Net::Ping;
11    
12  our $pids;  our $pids;
13  our $ports;  our $ports;
# Line 24  sub new { Line 25  sub new {
25  sub start_node {  sub start_node {
26          my ( $self, $host ) = @_;          my ( $self, $host ) = @_;
27    
28          system "rsync -rav /srv/Sack/ $host:/srv/Sack/";          chomp $host;
29    
30            my $p = Net::Ping->new;
31    
32            if ( ! $p->ping( $host ) ) {
33                    warn "can't ping [$host]\n";
34                    return;
35            }
36    
37            warn "start_node $host\n";
38    
39            my $ssh_config = '-F etc/lib.ssh';
40    
41          if ( my $pid = fork ) {          if ( my $pid = fork ) {
42                  # parent                  # parent
# Line 63  sub start_node { Line 75  sub start_node {
75                  return;                  return;
76          } else {          } else {
77                  # child                  # child
78    
79                  my $cmd = $host !~ m{^(localhost|127\.)}i ? qq|                  my $cmd = $host !~ m{^(localhost|127\.)}i ? qq|
80                          ssh                          ssh -f $ssh_config
81                                  -S /tmp/sock.$port.ssh                                  -S /tmp/sock.$port.ssh
82                                  -L $port:127.0.0.1:$port                                  -L $port:127.0.0.1:$port
83                          $host                          $host
# Line 159  sub merge { Line 172  sub merge {
172  sub view {  sub view {
173          my ( $self, $view ) = @_;          my ( $self, $view ) = @_;
174    
175            $out = {};
176    
177          warn "run view $view ", -s $view, " bytes\n";          warn "run view $view ", -s $view, " bytes\n";
178    
179          my $view_code = read_file($view);          my $view_code = read_file($view);
# Line 167  sub view { Line 182  sub view {
182          foreach my $port ( keys %{ $self->{connected} } ) {          foreach my $port ( keys %{ $self->{connected} } ) {
183                  warn "get_from $port\n";                  warn "get_from $port\n";
184                  my $result = $self->get_from( $port );                  my $result = $self->get_from( $port );
185  warn dump $result;                  warn "# result ", dump $result if $self->{debug};
186                  if ( $result->{view} ) {                  if ( $result->{view} ) {
187                          $self->merge( $result->{view} );                          $self->merge( $result->{view} );
188                  } else {                  } else {

Legend:
Removed from v.97  
changed lines
  Added in v.107

  ViewVC Help
Powered by ViewVC 1.1.26