From 781c552e6f366ece992bf4c9cff88ee9b3e555fc Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" Date: Thu, 27 Jan 2011 12:47:20 +0000 Subject: [PATCH] Allow jobqueue.pl to run once and then exit. r=mkanat. git-svn-id: svn://10.0.0.236/trunk@261849 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/.bzrrev | 2 +- .../bugzilla/Bugzilla/JobQueue/Runner.pm | 20 ++++++++++++++++++- mozilla/webtools/bugzilla/jobqueue.pl | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/mozilla/webtools/bugzilla/.bzrrev b/mozilla/webtools/bugzilla/.bzrrev index 971eec2a8ab..01efca50358 100644 --- a/mozilla/webtools/bugzilla/.bzrrev +++ b/mozilla/webtools/bugzilla/.bzrrev @@ -1 +1 @@ -7682 \ No newline at end of file +7683 \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/Bugzilla/JobQueue/Runner.pm b/mozilla/webtools/bugzilla/Bugzilla/JobQueue/Runner.pm index 20cf6439f65..26755e78f1b 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/JobQueue/Runner.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/JobQueue/Runner.pm @@ -196,16 +196,34 @@ sub gd_setup_signals { $SIG{TERM} = sub { $self->gd_quit_event(); } } +sub gd_other_cmd { + my ($self) = shift; + if ($ARGV[0] eq "once") { + $self->_do_work("work_once"); + + exit(0); + } + + $self->SUPER::gd_other_cmd(); +} + sub gd_run { my $self = shift; + $self->_do_work("work"); +} + +sub _do_work { + my ($self, $fn) = @_; + my $jq = Bugzilla->job_queue(); $jq->set_verbose($self->{debug}); foreach my $module (values %{ Bugzilla::JobQueue->job_map() }) { eval "use $module"; $jq->can_do($module); } - $jq->work; + + $jq->$fn; } 1; diff --git a/mozilla/webtools/bugzilla/jobqueue.pl b/mozilla/webtools/bugzilla/jobqueue.pl index 78490ddf0df..3d495c422ad 100755 --- a/mozilla/webtools/bugzilla/jobqueue.pl +++ b/mozilla/webtools/bugzilla/jobqueue.pl @@ -52,6 +52,8 @@ jobqueue.pl - Runs jobs in the background for Bugzilla. stop Stops a running jobqueue daemon restart Stops a running jobqueue if one is running, and then starts a new one. + once Checks the job queue once, executes the first item found (if + any) and then exits check Report the current status of the daemon. install On some *nix systems, this automatically installs and configures jobqueue.pl as a system service so that it will