--- trunk/lib/Sack/Server.pm 2010/02/04 18:15:59 265 +++ trunk/lib/Sack/Server.pm 2010/02/04 19:08:29 266 @@ -41,17 +41,14 @@ $sel->add( $www ); my $info; -sub info { - my $port = shift; - push @{ $info->{node}->{$port} }, [ @_ ]; -} sub fork_ssh { my ( $port, $host ) = @_; if ( my $pid = fork ) { # parent - info $port => 'forked', $pid; + $info->{forked}->{$port} = $pid; + $info->{pending}->{$port} = 'forked'; return $port; } elsif ( ! defined $pid ) { @@ -59,6 +56,9 @@ return; } else { # child + warn "[$port] cpio last version\n"; + system "find /srv/Sack/ | cpio --create --dereference | ssh -T -F $cloud_path.ssh $host cpio --extract --make-directories --unconditional"; + my $cmd = qq|ssh -F $cloud_path.ssh -R $port:127.0.0.1:$listen_port $host $node_path $port|; warn "# exec: $cmd\n"; exec $cmd; @@ -68,7 +68,6 @@ my $node_port = 4000; foreach my $host ( @cloud ) { - system "find /srv/Sack/ | cpio --create --dereference | ssh -T -F $cloud_path.ssh $host cpio --extract --make-directories --unconditional"; fork_ssh( $node_port++, $host ); } @@ -173,7 +172,8 @@ } my $refresh = $param->{refresh}; - $refresh = 1 if keys %{ $info->{pending} }; + $refresh = 1 if grep { $info->{pending}->{$_} ne 'forked' } keys %{ $info->{pending} }; + # we don't care about refresh is nodes are stuck in forked state! print $send "HTTP/1.0 200 OK\r\nContent-Type: text/html" , ( $refresh ? "\r\nRefresh: $refresh" : '' ) @@ -262,14 +262,12 @@ ; print $send qq|

Nodes

|; - foreach my $node ( keys %{ $info->{node} } ) { - my $class = join(' ' - , map { $_->[0] } @{ $info->{node}->{$node} } - ); + foreach my $node ( keys %{ $info->{forked} } ) { + my $attr = ''; if ( my $pending = $info->{pending}->{$node} ) { - $class .= " $pending"; + $attr .= qq| class="$pending"|; } - print $send qq|$node\n|; + print $send qq|$node\n|; } print $send qq|

Shards