1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
#!/usr/bin/perl -w
# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd.
# This program is distributed under the terms of the
# GNU General Public License, version 2.
#
# $Id: run-periodic-tasks 2380 2008-05-17 22:41:18Z bchoate $
use strict;
use lib '/usr/share/movabletype/extlib';
my $daemonize = 0;
my $sleep = 5;
my $help = 0;
my $load = 10;
my $verbose = 0;
my $scoreboard;
my $randomize_jobs = 0;
my $trace_objects = 0;
require Getopt::Long;
Getopt::Long::GetOptions(
"daemon" => \$daemonize,
"sleep=i" => \$sleep,
"load=i" => \$load,
"scoreboard=s" => \$scoreboard,
"randomly" => \$randomize_jobs,
"verbose" => \$verbose,
"leak" => \$trace_objects,
);
if ( $trace_objects ) {
require Devel::Leak::Object;
Devel::Leak::Object->import( qw{ GLOBAL_bless } );
}
my %cfg;
$cfg{verbose} = $verbose;
$cfg{scoreboard} = $scoreboard;
$cfg{prioritize} = 1;
$cfg{randomize} = $randomize_jobs;
require MT::Bootstrap;
require MT;
my $mt = MT->new() or die MT->errstr;
$mt->{vtbl} = { };
$mt->{is_admin} = 0;
$mt->{template_dir} = 'cms';
$mt->{user_class} = 'MT::Author';
$mt->{plugin_template_path} = 'tmpl';
$mt->run_callbacks('init_app', $mt);
my $client = eval {
require MT::TheSchwartz;
my $c = MT::TheSchwartz->new(%cfg);
no warnings 'once';
$TheSchwartz::FIND_JOB_BATCH_SIZE = $load;
$c;
};
if ((my $error = $@) && $verbose) {
print STDERR "Error initializing TheSchwartz: $error\n";
}
if ($daemonize && $client) {
$client->work_periodically($sleep);
} else {
# First, run periodic tasks
$mt->run_tasks();
$client->work_until_done if $client;
}
1;
|