root/branches/release-34/tools/run-periodic-tasks @ 1870

Revision 1870, 1.3 kB (checked in by bchoate, 20 months ago)

Prevent fatal error when attempting to use TheSchwartz without List::Util module. BugId:77208

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/usr/bin/perl -w
2
3# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd.
4# This program is distributed under the terms of the
5# GNU General Public License, version 2.
6#
7# $Id$
8
9use strict;
10
11use lib 'lib', '../lib';
12use MT::Bootstrap;
13use MT;
14
15my $mt = MT->new() or die MT->errstr;
16
17$mt->{vtbl} = { };
18$mt->{is_admin} = 0;
19$mt->{template_dir} = 'cms';
20$mt->{user_class} = 'MT::Author';
21$mt->{plugin_template_path} = 'tmpl';
22$mt->run_callbacks('init_app', $mt);
23
24require Getopt::Long;
25my $daemonize = 0;
26my $sleep     = 5;
27my $help      = 0;
28my $load      = 10;
29my $verbose   = 0;
30my $scoreboard;
31
32Getopt::Long::GetOptions(
33    "daemon"      => \$daemonize,
34    "sleep=i"     => \$sleep,
35    "load=i"      => \$load,
36    "scoreboard=s"=> \$scoreboard,
37    "verbose"     => \$verbose,
38);
39
40my %cfg;
41$cfg{verbose} = $verbose;
42$cfg{scoreboard} = $scoreboard;
43$cfg{prioritize} = 1;
44
45my $client = eval {
46    require MT::TheSchwartz;
47    my $c = MT::TheSchwartz->new(%cfg);
48    no warnings 'once';
49    $TheSchwartz::FIND_JOB_BATCH_SIZE = $load;
50    $c;
51};
52if ((my $error = $@) && $verbose) {
53    print STDERR "Error initializing TheSchwartz: $error\n";
54}
55
56if ($daemonize && $client) {
57    $client->work_periodically($sleep);
58} else {
59    # First, run periodic tasks
60    $mt->run_tasks();
61    $client->work_until_done if $client;
62}
63
641;
Note: See TracBrowser for help on using the browser.