]> dxcluster.org Git - spider.git/commitdiff
fix backgrounding of mrtg
authorDirk Koopman <djk@tobit.co.uk>
Thu, 18 Aug 2016 17:34:39 +0000 (18:34 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Thu, 18 Aug 2016 17:34:39 +0000 (18:34 +0100)
and new cron commands: spawn_cmd which will background any dxspider cmd

cmd/mrtg.pl
perl/DXCron.pm

index db2d2e1109bb52b641093ea19cff382a52719ca7..466d61134602e58e2f0602415b94d7825e8114f2 100644 (file)
@@ -32,6 +32,8 @@
 sub handle
 {
        my ($self, $line) = @_;
+
+       $DB::single = 1;
        
        # create the arg list
        my %want;
@@ -40,7 +42,7 @@ sub handle
        
        return (1, "MRTG not installed") unless $want{nomrtg} || -e '/usr/bin/mrtg' || -e '/usr/local/bin/mrtg';
 
-       my @out = $self->spawn_cmd("mrtg $line", \&do_it, args=>[%want]);
+       my @out = do_it(%want);
        
        return (1, @out);
 }
index f9a4f07ea12585ab62b30389b1c4734d341fa2eb..757ec61cd640756b6b6d7587c1e62f06143e81bc 100644 (file)
@@ -263,6 +263,29 @@ sub spawn
                        );
 }
 
+sub spawn_cmd
+{
+       my $line = shift;
+
+       dbg("spawn_cmd run: $line") if isdbg('cron');
+       my $fc = Mojo::IOLoop::ForkCall->new;
+       $fc->run(
+                        sub {my @res = DXCommandmode::run_cmd($main::me, $line); return @res},
+                        [],
+                        sub {
+                                my ($fc, $err, @res) = @_; 
+                                if (defined $err) {
+                                        my $s = "spawn_cmd: error $err";
+                                        dbg($s);
+                                }
+                                for (@res) {
+                                        chomp;
+                                        dbg("spawn_cmd: $_") if isdbg("cron");
+                                }
+                        }
+                       );
+}
+
 # do an rcmd to another cluster from the crontab
 sub rcmd
 {