$self->send_file($motd) if -e $motd;
}
-sub _diffms
-{
- return unless isdbg('chan');
- my $call = shift;
- my $line = shift;
- my $ta = shift;
- my $tb = shift || [gettimeofday];
-
- my $a = int($ta->[0] * 1000) + int($ta->[1] / 1000);
- my $b = int($tb->[0] * 1000) + int($tb->[1] / 1000);
- my $msecs = $b - $a;
-
- my $s = "forkcall stats: $call '$line' ";
- $s .= "${msecs}mS";
- dbg($s);
-}
# Punt off a long running command into a separate process
#
$s .= ", args: " . join(', ', @$args) if $args && @$args;
}
my @res = $cmdref->(@$args);
+# diffms("rcmd from $call 1", $line, $t0, scalar @res) if isdbg('chan');
return @res;
},
# $args,
return unless $dxchan;
if ($err) {
- my $s = "DXCommand::spawn_cmd: call $call error $err";
+ my $s = "DXProt::spawn_cmd: call $call error $err";
dbg($s) if isdbg('chan');
$dxchan->send($s);
return;
$dxchan->send(@res);
}
}
- _diffms($call, $line, $t0);
+ diffms("by $call", $line, $t0, scalar @res) if isdbg('chan');
});
return @out;
use DXDebug;
use IO::File;
use DXLog;
-
+use Time::HiRes qw(gettimeofday tv_interval);
use Mojo::IOLoop::Subprocess;
use strict;
sub spawn
{
my $line = shift;
+ my $t0 = [gettimeofday];
dbg("DXCron::spawn: $line") if isdbg("cron");
my $fc = Mojo::IOLoop::Subprocess->new();
$fc->run(
- sub {my @res = `$line`; return @res},
+ sub {
+ my @res = `$line`;
+# diffms("DXCron spawn 1", $line, $t0, scalar @res) if isdbg('chan');
+ return @res
+ },
sub {
my ($fc, $err, @res) = @_;
if ($err) {
chomp;
dbg("DXCron::spawn: $_") if isdbg("cron");
}
+ diffms("by DXCron::spawn", $line, $t0, scalar @res) if isdbg('chan');
}
);
}
sub spawn_cmd
{
my $line = shift;
+ my $t0 = [gettimeofday];
dbg("DXCron::spawn_cmd run: $line") if isdbg('cron');
my $fc = Mojo::IOLoop::Subprocess->new();
$main::me->{_nospawn} = 1;
my @res = $main::me->run_cmd($line);
delete $main::me->{_nospawn};
+# diffms("DXCron spawn_cmd 1", $line, $t0, scalar @res) if isdbg('chan');
return @res;
},
sub {
chomp;
dbg("DXCron::spawn_cmd: $_") if isdbg("cron");
}
+ diffms("by DXCron::spawn_cmd", $line, $t0, scalar @res) if isdbg('chan');
}
);
}
}
my @res = $cmdref->(@$args);
+# diffms("by $call 1", $line, $t0, scalar @res) if isdbg('chan');
return @res;
},
# $args,
$self->send(@res);
}
}
- DXCommandmode::_diffms($call, $line, $t0);
+ diffms("rcmd from $user on $call", $line, $t0, scalar @res) if isdbg('chan');
});
return @out;
use IO::File;
use File::Copy;
use Data::Dumper;
-
+use Time::HiRes qw(gettimeofday tv_interval);
use strict;
print_all_fields cltounix unpad is_callsign is_latlong
is_qra is_freq is_digits is_pctext is_pcflag insertitem deleteitem
is_prefix dd is_ipaddr $pi $d2r $r2d localdata localdata_mv
+ diffms
);
}
}
+# measure the time taken for something to happen; use Time::HiRes qw(gettimeofday tv_interval);
+sub diffms
+{
+ my $call = shift;
+ my $line = shift;
+ my $ta = shift;
+ my $no = shift;
+ my $tb = shift || [gettimeofday];
+
+ my $a = int($ta->[0] * 1000) + int($ta->[1] / 1000);
+ my $b = int($tb->[0] * 1000) + int($tb->[1] / 1000);
+ my $msecs = $b - $a;
+
+ $line =~ s|\s+$||;
+ my $s = "subprocess stats cmd: '$line' $call ${msecs}mS";
+ $s .= " $no lines" if $no;
+ DXDebug::dbg($s);
+}
use strict;
-use Mojolicious 7.26;
+# order here is important - DXDebug snarfs Carp et al so that Mojo errors go into the debug log
+use DXDebug;
+use Mojolicious 7.26;
use Mojo::IOLoop;
-use DXDebug;
use Msg;
use IntMsg;
use Internet;
use IsoTime;
use BPQMsg;
+
+
use Data::Dumper;
use IO::File;
use Fcntl ':flock';