]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Revert "Bug 832893: change jobqueue.pl to spawn worker processes to deliver bugmail...
authorDylan William Hardison <dylan@hardison.net>
Thu, 8 Mar 2018 20:40:10 +0000 (15:40 -0500)
committerGitHub <noreply@github.com>
Thu, 8 Mar 2018 20:40:10 +0000 (15:40 -0500)
This reverts commit 6df7b9816541893a905eec56c333b40673522e84.

Bugzilla/JobQueue.pm
Bugzilla/JobQueue/Runner.pm
jobqueue.pl

index b3b54de79dd2428d57c2421cfe58691df46cc53f..55d40bfb8ff57cd141d5d7423c3de337b93b8491 100644 (file)
@@ -14,9 +14,7 @@ use warnings;
 use Bugzilla::Constants;
 use Bugzilla::Error;
 use Bugzilla::Install::Util qw(install_string);
-use File::Slurp;
 use base qw(TheSchwartz);
-use fields qw(_worker_pidfile);
 
 # This maps job names for Bugzilla::JobQueue to the appropriate modules.
 # If you add new types of jobs, you should add a mapping here.
@@ -93,57 +91,6 @@ sub insert {
     return $retval;
 }
 
-# To avoid memory leaks/fragmentation which tends to happen for long running
-# perl processes; check for jobs, and spawn a new process to empty the queue.
-sub subprocess_worker {
-    my $self = shift;
-
-    my $command = "$0 -p '" . $self->{_worker_pidfile} . "' onepass";
-
-    while (1) {
-        my $time = (time);
-        my @jobs = $self->list_jobs({
-            funcname      => $self->{all_abilities},
-            run_after     => $time,
-            grabbed_until => $time,
-            limit         => 1,
-        });
-        if (@jobs) {
-            $self->debug("Spawning queue worker process");
-            # Run the worker as a daemon
-            system $command;
-            # And poll the PID to detect when the working has finished.
-            # We do this instead of system() to allow for the INT signal to
-            # interrup us and trigger kill_worker().
-            my $pid = read_file($self->{_worker_pidfile}, err_mode => 'quiet');
-            if ($pid) {
-                sleep(3) while(kill(0, $pid));
-            }
-            $self->debug("Queue worker process completed");
-        } else {
-            $self->debug("No jobs found");
-        }
-        sleep(5);
-    }
-}
-
-sub kill_worker {
-    my $self = Bugzilla->job_queue();
-    if ($self->{_worker_pidfile} && -e $self->{_worker_pidfile}) {
-        my $worker_pid = read_file($self->{_worker_pidfile});
-        if ($worker_pid && kill(0, $worker_pid)) {
-            $self->debug("Stopping worker process");
-            system "$0 -f -p '" . $self->{_worker_pidfile} . "' stop";
-        }
-    }
-}
-
-sub set_pidfile {
-    my ($self, $pidfile) = @_;
-    $pidfile =~ s/^(.+)(\..+)$/$1.worker$2/;
-    $self->{_worker_pidfile} = $pidfile;
-}
-
 # Clear the request cache at the start of each run.
 sub work_once {
     my $self = shift;
index 3adb918577ec108d82ba2e3638db47947224bf06..5b3164ef9cd9f3ad3ce2c760f24a03998061f37f 100644 (file)
@@ -39,7 +39,6 @@ our $initscript = "bugzilla-queue";
 sub gd_preconfig {
     my $self = shift;
 
-    $self->{_run_command} = 'subprocess_worker';
     my $pidfile = $self->{gd_args}{pidfile};
     if (!$pidfile) {
         $pidfile = bz_locations()->{datadir} . '/' . $self->{gd_progname}
@@ -180,26 +179,21 @@ sub gd_setup_signals {
     $SIG{TERM} = sub { $self->gd_quit_event(); }
 }
 
-sub gd_quit_event {
-    Bugzilla->job_queue->kill_worker();
-    exit(1);
-}
-
 sub gd_other_cmd {
-    my ($self, $do, $locked) = @_;
-    if ($do eq "once") {
-        $self->{_run_command} = 'work_once';
-    } elsif ($do eq "onepass") {
-        $self->{_run_command} = 'work_until_done';
-    } else {
-        $self->SUPER::gd_other_cmd($do, $locked);
+    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;
-    $SIG{__DIE__} = \&Carp::confess if $self->{debug};
-    $self->_do_work($self->{_run_command});
+
+    $self->_do_work("work");
 }
 
 sub _do_work {
@@ -207,7 +201,6 @@ sub _do_work {
 
     my $jq = Bugzilla->job_queue();
     $jq->set_verbose($self->{debug});
-    $jq->set_pidfile($self->{gd_pidfile});
     foreach my $module (values %{ Bugzilla::JobQueue->job_map() }) {
         eval "use $module";
         $jq->can_do($module);
index 011d0ff87b9f5545163995a4c77e0ba59109e100..f5541e0fb8a96638873b8408e3cb75c82f9f628f 100755 (executable)
@@ -46,8 +46,7 @@ jobqueue.pl - Runs jobs in the background for Bugzilla.
    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, up to a limit of 1000 items) and then exits
-   onepass   Checks the job queue, executes all items found, and then exits
+             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