Skip to content

Instantly share code, notes, and snippets.

@diegok
Last active August 29, 2015 14:05
Show Gist options
  • Save diegok/2179141fc9de769b1e59 to your computer and use it in GitHub Desktop.
Save diegok/2179141fc9de769b1e59 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use Resque;
use Company::Config;
use Getopt::Long::Descriptive;
require UNIVERSAL::require;
my $opt = getopt();
$_->require for @{$opt->module||[]};
my $w = Resque->new( redis => Company::Config->new->redis )->worker;
$w->interval($opt->interval);
$w->add_queue(@{$opt->queue});
$w->verbose($opt->verbose);
$w->cant_fork($opt->cant_fork);
$w->work;
sub getopt {
my ($opt, $usage) = describe_options(
'resque-worker %o <some-arg>',
[ 'queue|q=s@', "queue name (Default: test)", { default => 'test' } ],
[ 'interval|i=f', "Polling interval in floating seconds for this resque worker (Default 5 seconds)", { default => 5 } ],
[ 'cant_fork|f', "Don't let resque fork" ],
[ 'module|M=s@', "Modules to load before forking occurs" ],
[ 'verbose|v', "set resque worker to be verbose" ],
[ 'help', "print usage message and exit" ],
);
print($usage->text), exit if $opt->help;
return $opt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment