]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Allow jobqueue.pl to run once and then exit. r=mkanat.
authorGervase Markham <gerv@gerv.net>
Thu, 27 Jan 2011 12:42:01 +0000 (12:42 +0000)
committerGervase Markham <gerv@mozilla.org>
Thu, 27 Jan 2011 12:42:01 +0000 (12:42 +0000)
https://bugzilla.mozilla.org/show_bug.cgi?id=621256

Bugzilla/JobQueue/Runner.pm
jobqueue.pl

index 20cf6439f6504a02127e3a5523308336eaebeefb..26755e78f1b9ac54d2f6243df9c4318576d3311f 100644 (file)
@@ -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;
index 78490ddf0df4260ac8247e1d94efba40844f072c..3d495c422ad419340c9eb67953a25c5e858c0b21 100755 (executable)
@@ -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