|
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 | |
|---|
| 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 $load = 10; |
|---|
| 29 | my $verbose = 0; |
|---|
| 30 | my $scoreboard; |
|---|
| 31 | |
|---|
| 32 | Getopt::Long::GetOptions( |
|---|
| 33 | "daemon" => \$daemonize, |
|---|
| 34 | "sleep=i" => \$sleep, |
|---|
| 35 | "load=i" => \$load, |
|---|
| 36 | "scoreboard=s"=> \$scoreboard, |
|---|
| 37 | "verbose" => \$verbose, |
|---|
| 38 | ); |
|---|
| 39 | |
|---|
| 40 | my %cfg; |
|---|
| 41 | $cfg{verbose} = $verbose; |
|---|
| 42 | $cfg{scoreboard} = $scoreboard; |
|---|
| 43 | $cfg{prioritize} = 1; |
|---|
| 44 | |
|---|
| 45 | my $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 | }; |
|---|
| 52 | if ((my $error = $@) && $verbose) { |
|---|
| 53 | print STDERR "Error initializing TheSchwartz: $error\n"; |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | if ($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 | |
|---|
| 64 | 1; |
|---|