root/branches/release-38/tools/run-periodic-tasks @ 2380

Revision 2380, 1.6 kB (checked in by bchoate, 19 months ago)

Fixed path for perl.

  • 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';
12
13my $daemonize = 0;
14my $sleep     = 5;
15my $help      = 0;
16my $load      = 10;
17my $verbose   = 0;
18my $scoreboard;
19my $randomize_jobs = 0;
20my $trace_objects = 0;
21
22require Getopt::Long;
23Getopt::Long::GetOptions(
24    "daemon"       => \$daemonize,
25    "sleep=i"      => \$sleep,
26    "load=i"       => \$load,
27    "scoreboard=s" => \$scoreboard,
28    "randomly"     => \$randomize_jobs,
29    "verbose"      => \$verbose,
30    "leak"         => \$trace_objects,
31);
32
33if ( $trace_objects ) {
34    require Devel::Leak::Object;
35    Devel::Leak::Object->import( qw{ GLOBAL_bless } );
36}
37
38my %cfg;
39$cfg{verbose} = $verbose;
40$cfg{scoreboard} = $scoreboard;
41$cfg{prioritize} = 1;
42$cfg{randomize} = $randomize_jobs;
43
44require MT::Bootstrap;
45require MT;
46
47my $mt = MT->new() or die MT->errstr;
48
49$mt->{vtbl} = { };
50$mt->{is_admin} = 0;
51$mt->{template_dir} = 'cms';
52$mt->{user_class} = 'MT::Author';
53$mt->{plugin_template_path} = 'tmpl';
54$mt->run_callbacks('init_app', $mt);
55
56my $client = eval {
57    require MT::TheSchwartz;
58    my $c = MT::TheSchwartz->new(%cfg);
59    no warnings 'once';
60    $TheSchwartz::FIND_JOB_BATCH_SIZE = $load;
61    $c;
62};
63if ((my $error = $@) && $verbose) {
64    print STDERR "Error initializing TheSchwartz: $error\n";
65}
66
67if ($daemonize && $client) {
68    $client->work_periodically($sleep);
69} else {
70    # First, run periodic tasks
71    $mt->run_tasks();
72    $client->work_until_done if $client;
73}
74
751;
Note: See TracBrowser for help on using the browser.