| Catalyst-Engine-JobQueue-POE documentation | Contained in the Catalyst-Engine-JobQueue-POE distribution. |
Catalyst::Helper::JobQueue::POE - create files for running a job queue
script/create.pl JobQueue::POE
This helper creates the required files for a job queue. It creates a JobQueue runner script in your application's script directory and a crontab configuration file in your applications root directory.
After editing your configuration file, you can start the job queue by executing the runner script.
Generates a JobQueue runner script and a sample crontab file.
Gruen Christian-Rolf <kiki@bdsro.org>
[% appprefix %]_jobqueue.pl - Catalyst JobQueue
[% appprefix %]_jobqueue.pl [options]
Options:
-d -debug force debug mode
-f -fork handle each request in a new process
(defaults to false)
-c -crontab name of the crontab file
-? -help display this help and exits
See also:
perldoc Catalyst::Manual
perldoc Catalyst::Manual::Intro
Run a Catalyst JobQueue for this application.
Gruen Christian-Rolf, kiki@bsdro.org
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
| Catalyst-Engine-JobQueue-POE documentation | Contained in the Catalyst-Engine-JobQueue-POE distribution. |
package Catalyst::Helper::JobQueue::POE; use strict; use warnings; use version; our $VERSION = qv('0.0.1'); our $CATALYST_SCRIPT_GEN = 30;
sub mk_stuff { my ( $self, $helper, @args ) = @_; $self->_mk_jobqueue($helper, @args); $self->_mk_crontab($helper, @args); } sub _mk_jobqueue { my ( $self, $helper, @args ) = @_; my $base = $helper->{base}; my $app = $helper->{app}; my $appprefix = lc($app); $appprefix =~ s/::/_/; my $filename = File::Spec->catfile( $base, 'script', "${appprefix}_jobqueue.pl"); $helper->render_file( 'jobqueue', $filename, { appprefix => $appprefix, scriptgen => $CATALYST_SCRIPT_GEN } ); chmod 0700, $filename; } sub _mk_crontab { my ( $self, $helper, @args ) = @_; my $base = $helper->{base}; my $filename = File::Spec->catfile( $base, "crontab" ); $helper->render_file( 'crontab', $filename ); } return 1; __DATA__ __jobqueue__ #!env perl -w BEGIN { $ENV{CATALYST_ENGINE} = 'JobQueue::POE'; $ENV{CATALYST_SCRIPT_GEN} = [% scriptgen %]; } use strict; use warnings; use Getopt::Long; use Pod::Usage; use FindBin; use lib "$FindBin::Bin/../lib"; $ENV{CATALYST_HOME} = "$FindBin::Bin/.."; my $debug = 0; my $fork = 0; my $help = 0; my $crontab = "$FindBin::Bin/crontab"; my @argv = @ARGV; GetOptions( 'debug|d' => \$debug, 'fork' => \$fork, 'help|?' => \$help, 'crontab|c' => \$crontab, ); pod2usage(1) if $help; if ( $debug ) { $ENV{CATALYST_DEBUG} = 1; $ENV{CATALYST_POE_DEBUG} = 1; } # This is require instead of use so that the above environment # variables can be set at runtime. require [% app %]; [% app %]->run( { argv => \@argv, 'fork' => $fork, crontab => $crontab, } ); 1;
__crontab__ # JobQueue crontab # #minute hour mday month wday who command # #* * * * * root /test/job