projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
put dx.pl into an explicit handle sub
[spider.git]
/
perl
/
DXCron.pm
diff --git
a/perl/DXCron.pm
b/perl/DXCron.pm
index 757ec61cd640756b6b6d7587c1e62f06143e81bc..c011d7b3d3e3df0740bfbdc3662edd6646b95d30 100644
(file)
--- a/
perl/DXCron.pm
+++ b/
perl/DXCron.pm
@@
-15,6
+15,8
@@
use DXDebug;
use IO::File;
use DXLog;
use IO::File;
use DXLog;
+use Mojo::IOLoop::Subprocess;
+
use strict;
use vars qw{@crontab @lcrontab @scrontab $mtime $lasttime $lastmin};
use strict;
use vars qw{@crontab @lcrontab @scrontab $mtime $lasttime $lastmin};
@@
-60,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++;
@@
-79,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);
@@
-244,13
+246,13
@@
sub spawn
{
my $line = shift;
{
my $line = shift;
- my $fc = Mojo::IOLoop::ForkCall->new;
+ dbg("DXCron::spawn: $line") if isdbg("cron");
+ my $fc = Mojo::IOLoop::Subprocess->new();
$fc->run(
sub {my @res = `$line`; return @res},
$fc->run(
sub {my @res = `$line`; return @res},
- [],
sub {
my ($fc, $err, @res) = @_;
sub {
my ($fc, $err, @res) = @_;
- if (
defined
$err) {
+ if ($err) {
my $s = "DXCron::spawn: error $err";
dbg($s);
return;
my $s = "DXCron::spawn: error $err";
dbg($s);
return;
@@
-267,20
+269,24
@@
sub spawn_cmd
{
my $line = shift;
{
my $line = shift;
- dbg("spawn_cmd run: $line") if isdbg('cron');
- my $fc = Mojo::IOLoop::
ForkCall->new
;
+ dbg("
DXCron::
spawn_cmd run: $line") if isdbg('cron');
+ my $fc = Mojo::IOLoop::
Subprocess->new()
;
$fc->run(
$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};
+ return @res;
+ },
sub {
my ($fc, $err, @res) = @_;
sub {
my ($fc, $err, @res) = @_;
- if (
defined
$err) {
- my $s = "spawn_cmd: error $err";
+ if ($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");
}
}
);
}
}
);
@@
-303,12
+309,13
@@
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');
}
}
}
}
+
1;
__END__
1;
__END__