summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2009-08-18 07:33:45 +0200
committermkanat%bugzilla.org <>2009-08-18 07:33:45 +0200
commit9ced0509261dacaa617c39d32ed2c2a4297f0cb2 (patch)
treef8db3269362a384cc9b0a15eb0d88ee002092be3 /Bugzilla
parent5f725ca6ee9edb009af450d79ab7a0f88c059e8d (diff)
downloadbugzilla-9ced0509261dacaa617c39d32ed2c2a4297f0cb2.tar.gz
bugzilla-9ced0509261dacaa617c39d32ed2c2a4297f0cb2.tar.xz
Bug 509539: Allow jobqueue.pl to specify where it stores its PID
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=dkl, a=mkanat
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/JobQueue/Runner.pm56
1 files changed, 47 insertions, 9 deletions
diff --git a/Bugzilla/JobQueue/Runner.pm b/Bugzilla/JobQueue/Runner.pm
index ec2719638..3c392209a 100644
--- a/Bugzilla/JobQueue/Runner.pm
+++ b/Bugzilla/JobQueue/Runner.pm
@@ -35,18 +35,56 @@ use Bugzilla::JobQueue;
use Bugzilla::Util qw(get_text);
BEGIN { eval "use base qw(Daemon::Generic)"; }
-# Required because of a bug in Daemon::Generic where it won't use the
-# "version" key from DAEMON_CONFIG.
our $VERSION = BUGZILLA_VERSION;
-use constant DAEMON_CONFIG => (
- progname => basename($0),
- pidfile => bz_locations()->{datadir} . '/' . basename($0) . '.pid',
- version => BUGZILLA_VERSION,
-);
-
+# The Daemon::Generic docs say that it uses all sorts of
+# things from gd_preconfig, but in fact it does not. The
+# only thing it uses from gd_preconfig is the "pidfile"
+# config parameter.
sub gd_preconfig {
- return DAEMON_CONFIG;
+ my $self = shift;
+
+ my $pidfile = $self->{gd_args}{pidfile};
+ if (!$pidfile) {
+ $pidfile = bz_locations()->{datadir} . '/' . $self->{gd_progname}
+ . ".pid";
+ }
+ return (pidfile => $pidfile);
+}
+
+# All config other than the pidfile has to be done in gd_getopt
+# in order for it to be set up early enough.
+sub gd_getopt {
+ my $self = shift;
+
+ $self->SUPER::gd_getopt();
+
+ if ($self->{gd_args}{progname}) {
+ $self->{gd_progname} = $self->{gd_args}{progname};
+ }
+ else {
+ $self->{gd_progname} = basename($0);
+ }
+
+ # There are places that Daemon Generic's new() uses $0 instead of
+ # gd_progname, which it really shouldn't, but this hack fixes it.
+ $self->{_original_zero} = $0;
+ $0 = $self->{gd_progname};
+}
+
+sub gd_postconfig {
+ my $self = shift;
+ # See the hack above in gd_getopt. This just reverses it
+ # in case anything else needs the accurate $0.
+ $0 = delete $self->{_original_zero};
+}
+
+sub gd_more_opt {
+ my $self = shift;
+ return (
+ 'pidfile=s' => \$self->{gd_args}{pidfile},
+ 'n=s' => \$self->{gd_args}{progname},
+ );
}
sub gd_usage {