projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
improve spawn dbg, move "use Mojolicious"
[spider.git]
/
perl
/
DXCron.pm
diff --git
a/perl/DXCron.pm
b/perl/DXCron.pm
index e60d36b4ba8f02f934c2842a030c57cde11c4cfb..9a3aac50495b80716f07a67e7efa93ee921ab04d 100644
(file)
--- a/
perl/DXCron.pm
+++ b/
perl/DXCron.pm
@@
-14,7
+14,7
@@
use DXM;
use DXDebug;
use IO::File;
use DXLog;
use DXDebug;
use IO::File;
use DXLog;
-
+use Time::HiRes qw(gettimeofday tv_interval);
use Mojo::IOLoop::Subprocess;
use strict;
use Mojo::IOLoop::Subprocess;
use strict;
@@
-62,7
+62,7
@@
sub cread
my $line = 0;
my @out;
my $line = 0;
my @out;
- dbg("
cron:
reading $fn\n") if isdbg('cron');
+ dbg("
DXCron::cread
reading $fn\n") if isdbg('cron');
open($fh, $fn) or confess("cron: can't open $fn $!");
while (<$fh>) {
$line++;
open($fh, $fn) or confess("cron: can't open $fn $!");
while (<$fh>) {
$line++;
@@
-81,9
+81,9
@@
sub cread
if (!$err) {
$ref->{cmd} = $cmd;
push @out, $ref;
if (!$err) {
$ref->{cmd} = $cmd;
push @out, $ref;
- dbg("
cron
: adding $_\n") if isdbg('cron');
+ dbg("
DXCron::cread
: adding $_\n") if isdbg('cron');
} else {
} else {
- dbg("
cron
: error on line $line '$_'\n") if isdbg('cron');
+ dbg("
DXCron::cread
: error on line $line '$_'\n") if isdbg('cron');
}
}
close($fh);
}
}
close($fh);
@@
-245,11
+245,16
@@
sub start_connect
sub spawn
{
my $line = shift;
sub spawn
{
my $line = shift;
+ my $t0 = [gettimeofday];
+ dbg("DXCron::spawn: $line") if isdbg("cron");
my $fc = Mojo::IOLoop::Subprocess->new();
$fc->run(
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) {
sub {
my ($fc, $err, @res) = @_;
if ($err) {
@@
-261,6
+266,7
@@
sub spawn
chomp;
dbg("DXCron::spawn: $_") if isdbg("cron");
}
chomp;
dbg("DXCron::spawn: $_") if isdbg("cron");
}
+ diffms("by DXCron::spawn", $line, $t0, scalar @res) if isdbg('chan');
}
);
}
}
);
}
@@
-268,22
+274,29
@@
sub spawn
sub spawn_cmd
{
my $line = shift;
sub spawn_cmd
{
my $line = shift;
+ my $t0 = [gettimeofday];
- dbg("spawn_cmd run: $line") if isdbg('cron');
+ dbg("
DXCron::
spawn_cmd run: $line") if isdbg('cron');
my $fc = Mojo::IOLoop::Subprocess->new();
$fc->run(
my $fc = Mojo::IOLoop::Subprocess->new();
$fc->run(
- sub {my @res = DXCommandmode::run_cmd($main::me, $line); return @res},
-# [],
+ sub {
+ $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 {
my ($fc, $err, @res) = @_;
if ($err) {
sub {
my ($fc, $err, @res) = @_;
if ($err) {
- my $s = "spawn_cmd: error $err";
+ my $s = "
DXCron::
spawn_cmd: error $err";
dbg($s);
}
for (@res) {
chomp;
dbg($s);
}
for (@res) {
chomp;
- dbg("spawn_cmd: $_") if isdbg("cron");
+ dbg("
DXCron::
spawn_cmd: $_") if isdbg("cron");
}
}
+ diffms("by DXCron::spawn_cmd", $line, $t0, scalar @res) if isdbg('chan');
}
);
}
}
);
}
@@
-305,11
+318,11
@@
sub rcmd
sub run_cmd
{
my $line = shift;
sub run_cmd
{
my $line = shift;
- my @in =
DXCommandmode::run_cmd($main::me,
$line);
- dbg("
cmd run
: $line") if isdbg('cron');
+ my @in =
$main::me->run_cmd(
$line);
+ dbg("
DXCron::run_cmd
: $line") if isdbg('cron');
for (@in) {
s/\s*$//og;
for (@in) {
s/\s*$//og;
- dbg("cmd out: $_") if isdbg('cron');
+ dbg("
DXCron::
cmd out: $_") if isdbg('cron');
}
}
}
}