|
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 | |
|---|
| 9 | use strict; |
|---|
| 10 | |
|---|
| 11 | use lib 'lib', '../lib'; |
|---|
| 12 | use MT::Bootstrap; |
|---|
| 13 | use MT; |
|---|
| 14 | |
|---|
| 15 | my $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 | |
|---|
| 24 | require Getopt::Long; |
|---|
| 25 | my $daemonize = 0; |
|---|
| 26 | my $sleep = 5; |
|---|
| 27 | my $help = 0; |
|---|
| 28 | # my $sync = 0; |
|---|
| 29 | # my $rsync_opt = ''; |
|---|
| 30 | my $load = 10; |
|---|
| 31 | my $verbose = 0; |
|---|
| 32 | my $scoreboard; |
|---|
| 33 | |
|---|
| 34 | Getopt::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 | |
|---|
| 48 | my %cfg; |
|---|
| 49 | $cfg{verbose} = $verbose; |
|---|
| 50 | $cfg{scoreboard} = $scoreboard; |
|---|
| 51 | $cfg{prioritize} = 1; |
|---|
| 52 | |
|---|
| 53 | require MT::TheSchwartz; |
|---|
| 54 | my $client = MT::TheSchwartz->new(%cfg); |
|---|
| 55 | no warnings 'once'; |
|---|
| 56 | $TheSchwartz::FIND_JOB_BATCH_SIZE = $load; |
|---|
| 57 | |
|---|
| 58 | if ($daemonize) { |
|---|
| 59 | $client->work_periodically($sleep); |
|---|
| 60 | } else { |
|---|
| 61 | # First, run periodic tasks |
|---|
| 62 | $mt->run_tasks(); |
|---|
| 63 | $client->work_until_done; |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | 1; |
|---|