]> dxcluster.org Git - spider.git/blob - cmd/connect.pl
added some more filter help
[spider.git] / cmd / connect.pl
1 #
2 # connect a cluster station
3 #
4 my $self = shift;
5 my $call = uc shift;
6 my $lccall = lc $call;
7
8 return (1, $self->msg('e5')) if $self->priv < 5;
9 return (1, $self->msg('e6')) unless $call gt ' ';
10 return (1, $self->msg('already', $call)) if DXChannel->get($call);
11 return (1, $self->msg('outconn', $call)) if grep {$_->{call} eq $call} @main::outstanding_connects;
12 return (1, $self->msg('conscript', $lccall)) unless -e "$main::root/connect/$lccall";
13
14 my $prog = "$main::root/local/client.pl";
15 $prog = "$main::root/perl/client.pl" if ! -e $prog;
16
17 my $pid = fork();
18 if (defined $pid) {
19         if (!$pid) {
20                 # in child, unset warnings, disable debugging and general clean up from us
21                 $^W = 0;
22                 $SIG{HUP} = 'IGNORE';
23                 eval "{ package DB; sub DB {} }";
24                 alarm(0);
25                 DXChannel::closeall();
26                 Msg::close_server();
27                 $SIG{CHLD} = $SIG{TERM} = $SIG{INT} = $SIG{__WARN__} = 'DEFAULT';
28                 exec $prog, $call, 'connect';
29         } else {
30                 sleep(1);    # do a coordination
31                 push @main::outstanding_connects, {call => $call, pid => $pid};
32                 return(1, $self->msg('constart', $call));
33         }
34 }
35 return (0, $self->msg('confail', $call, $!))
36
37
38