root/branches/release-30/tools/run-periodic-tasks @ 1407

Revision 1407, 1.4 kB (checked in by bchoate, 21 months ago)

Updated with job prioritization support.

  • 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;
28# my $sync      = 0;
29# my $rsync_opt = '';
30my $load      = 10;
31my $verbose   = 0;
32my $scoreboard;
33
34Getopt::Long::GetOptions(
35    "daemon"      => \$daemonize,
36    "sleep=i"     => \$sleep,
37    # "help|?"      => \$help,
38    # "throttle=i"  => \%throttle,
39    # "worker=s"    => \$worker,
40    # "sync"        => \$sync,
41    # "to|target=s" => \@target,
42    # "rsync=s"     => \$rsync_opt,
43    "load=i"      => \$load,
44    "scoreboard=s"=> \$scoreboard,
45    "verbose"     => \$verbose,
46);
47
48my %cfg;
49$cfg{verbose} = $verbose;
50$cfg{scoreboard} = $scoreboard;
51$cfg{prioritize} = 1;
52
53require MT::TheSchwartz;
54my $client = MT::TheSchwartz->new(%cfg);
55no warnings 'once';
56$TheSchwartz::FIND_JOB_BATCH_SIZE = $load;
57
58if ($daemonize) {
59    $client->work_periodically($sleep);
60} else {
61    # First, run periodic tasks
62    $mt->run_tasks();
63    $client->work_until_done;
64}
65
661;
Note: See TracBrowser for help on using the browser.