21 my @opt = <<'=back' =~ /B<--(\S+)>/g;
29 Sleep that much between two calls to distrofacts.
33 Even more verbose than we already are by default (but this may change)
39 Our first iteration is just a letter of intent that we want to become
40 better on empty pages.
44 Up to commit 32b522a we were using
46 redis->srandmember("analysis:distv:legalset")
48 but that started to dry out mid-July 2014, so we switched to a
49 postgres implementation.
55 use lib
"$FindBin::Bin/../lib";
61 use File
::Basename
qw(dirname);
62 use File
::Path
qw(mkpath);
67 use Hash
::Util
qw(lock_keys);
68 use Time
::HiRes
qw(sleep);
71 lock_keys
%Opt, map { /([^=|!]+)/ } @opt;
82 use lib
"$FindBin::Bin/../CPAN-Blame/lib";
83 use CPAN
::Blame
::Config
::Cnntp
;
85 $workdir = File
::Spec
->catdir
86 ($CPAN::Blame
::Config
::Cnntp
::Config
->{solver_vardir
},
89 use IPC
::ConcurrencyLimit
;
91 my($basename) = File
::Basename
::basename
(__FILE__
);
92 my $limit = IPC
::ConcurrencyLimit
->new
95 path
=> "$workdir/IPC-ConcurrencyLimit-$basename",
97 my $limitid = $limit->get_lock;
99 warn "Another process appears to be still running. Exiting.";
104 my $redis = Redis
->new(reconnect
=> 120, every
=> 1000);
107 my $dbi = DBI
->connect ("dbi:Pg:dbname=analysis");
109 my $sth = mypgdbi
()->prepare("SELECT EXTRACT(EPOCH FROM cuti_ts) from distlookup where distv=?");
110 my $sth2 = mypgdbi
()->prepare("SELECT cuti_ts is null as N0, count(*) from distlookup group by N0");
111 my $sth3 = mypgdbi
()->prepare("SELECT distv from distlookup where (cuti_ts is null or now() - cuti_ts > ?) and distv not like '%-' limit 1");
113 setpriority(0, 0, 5); # renice
115 $sth3->execute("$start_days days");
116 if ($sth3->rows <= 0){
117 if ($start_days > 1) {
125 my($distv) = $sth3->fetchrow_array;
126 next if $distv =~ /-$/; # MyConfig2- KeywordsSpider- BitArray1- (last one reported to Barbie)
127 warn "Running 'cnntp-solver.pl --cpanstats_distrofacts $distv'" if $Opt{verbose
};
128 my @system = ($^X
,"$FindBin::Bin/cnntp-solver.pl", "--cpanstats_distrofacts", $distv);
129 0 == system(@system) or die "Problems while running '@system'";
130 my($legalset_total) = $redis->scard("analysis:distv:legalset");
131 my($calctimestamp_total) = $redis->zcard("analysis:distv:calctimestamp");
132 my($uncounted_total, $counted_total);
135 while (my @row = $sth2->fetchrow_array) {
137 $uncounted_total = $row[1];
139 $counted_total = $row[1];
143 warn "distv[$distv]redis:legalset_total[$legalset_total]redis:calctimestamp_total[$calctimestamp_total]pg:uncounted_total[$uncounted_total]pg:counted_total[$counted_total]\n";
149 # cperl-indent-level: 4