Last Comment Bug 475403 - A RHEL SysV Init Script for jobqueue.pl
: A RHEL SysV Init Script for jobqueue.pl
Status: RESOLVED FIXED
[es-gnome]
:
Product: Bugzilla
Classification: Server Software
Component: Administration (show other bugs)
: 3.3
: All All
: -- enhancement (vote)
: Bugzilla 3.4
Assigned To: Max Kanat-Alexander
: default-qa
:
Mentors:
Depends on: 509328 509539
Blocks:
  Show dependency treegraph
 
Reported: 2009-01-26 13:02 PST by Max Kanat-Alexander
Modified: 2010-02-28 10:54 PST (History)
3 users (show)
mkanat: approval+
mkanat: approval3.4+
See Also:
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
v1 (2.39 KB, patch)
2009-08-09 11:54 PDT, Max Kanat-Alexander
justdave: review-
Details | Diff | Splinter Review
v2 (3.52 KB, patch)
2009-08-09 12:43 PDT, Max Kanat-Alexander
no flags Details | Diff | Splinter Review
v3 (2.82 KB, patch)
2009-08-10 10:18 PDT, Max Kanat-Alexander
no flags Details | Diff | Splinter Review
v4 (9.54 KB, patch)
2009-08-10 16:18 PDT, Max Kanat-Alexander
mkanat: review-
Details | Diff | Splinter Review
v5 (9.29 KB, patch)
2009-08-14 23:31 PDT, Max Kanat-Alexander
dkl: review+
Details | Diff | Splinter Review

Description Max Kanat-Alexander 2009-01-26 13:02:53 PST
It would be nice to have a SysV init script for jobqueue.pl, so that it could be started as a daemon on startup and controlled by the normal sysv init tools, and all.

I can write one for RHEL, I may do that, and it could go into contrib/
Comment 1 Max Kanat-Alexander 2009-08-09 11:54:22 PDT
Created attachment 393449 [details] [diff] [review]
v1

Okay, here we go! Tested this on landfill.
Comment 2 Dave Miller [:justdave] (justdave@bugzilla.org) 2009-08-09 12:24:55 PDT
Comment on attachment 393449 [details] [diff] [review]
v1

>+# chkconfig: 2345 15 85
>+# description: Bugzilla queue runner

This ^^ (for RHEL)

>+### BEGIN INIT INFO
>+# Default-Start: 3 5
>+# Default-Stop: 0 1 2 6
>+# Short-Description: Start and stop the Bugzilla queue runner.
>+# Description: The Bugzilla queue runner (jobqueue.pl) sends any mail
>+#	that Bugzilla has queued to be sent in the background. If you
>+#	have enabled the use_mailer_queue parameter in Bugzilla, you
>+#	must run this daemon.
>+### END INIT INFO

Doesn't match this ^^ (for Fedora)

I assume both still use the same runlevels, so the configs for such should probably match, too.  Upstart is dependency based, so we probably want to tell Upstart that we depend on an MTA and mysqld, and document that MTA can be removed if you use remote SMTP, and mysqld should be changed to postgres if you use Pg locally, or removed if you use a remote DB.

Start/stop order numbers for RHEL/sysvinit (the 15 and 85 above) should also be changed to start after sendmail/postfix/mysqld/postgres, and shut down before those.

>+#################
>+# Configuration #
>+#################
>+
>+# This should be the path to your Bugzilla
>+BUGZILLA=/var/www/html/bugzilla
>+# Who owns the Bugzilla directory and files?
>+USER=root
>+# If you want to pass any options to the daemon (like -d for debugging)
>+# specify it here.
>+OPTIONS=""

Probably be useful to let people override these cleanly without having to edit the script (as an assistance to packagers)

if [ -r /etc/sysconfig/bugzilla-queue ]; then
   . /etc/sysconfig/bugzilla-queue
fi
Comment 3 Max Kanat-Alexander 2009-08-09 12:43:57 PDT
Created attachment 393456 [details] [diff] [review]
v2

Okay, this addresses all the comments.
Comment 4 Dave Miller [:justdave] (justdave@bugzilla.org) 2009-08-09 13:04:22 PDT
Comment on attachment 393456 [details] [diff] [review]
v2

>+    reload) RETVAL=3 ;;

reload is a no-op?
Comment 5 Max Kanat-Alexander 2009-08-10 10:18:13 PDT
Created attachment 393534 [details] [diff] [review]
v3

Ah yeah, thanks for catching that. :-)
Comment 6 Dave Miller [:justdave] (justdave@bugzilla.org) 2009-08-10 10:57:29 PDT
Comment on attachment 393534 [details] [diff] [review]
v3

- seems to be missing the documentation patch on this one that was included in the last one.

- Just realized that the pidfile usage here will break the way we have it set up on b.m.o... $BUGZILLA/data is an NFS mount shared by all of the webheads.  We run a queue runner on each webhead.  They would overwrite each others' PIDFILEs.  Probably better to drop the PIDFILE in /var/run/$NAME.pid instead
Comment 7 Dave Miller [:justdave] (justdave@bugzilla.org) 2009-08-10 10:59:08 PDT
The documentation in the v2 patch also doesn't mention the potential need to remove MTA or to remove or alter mysqld depending on your system setup when using Upstart, either.
Comment 8 Max Kanat-Alexander 2009-08-10 11:31:18 PDT
(In reply to comment #6)
> - Just realized that the pidfile usage here will break the way we have it set
> up on b.m.o... $BUGZILLA/data is an NFS mount shared by all of the webheads. 
> We run a queue runner on each webhead.  They would overwrite each others'
> PIDFILEs.  Probably better to drop the PIDFILE in /var/run/$NAME.pid instead

  The pidfile is being created by jobqueue.pl, not by bugzilla-queue. If you have that setup, it's already broken in that way.
Comment 9 Dave Miller [:justdave] (justdave@bugzilla.org) 2009-08-10 11:47:26 PDT
(In reply to comment #8)
>   The pidfile is being created by jobqueue.pl, not by bugzilla-queue. If you
> have that setup, it's already broken in that way.

But the initscript is telling it where to put the pid file and could easily change the location.  And we're not using jobqueue.pl (yet), we're still using theschwartz-worker.pl from the old hack.
Comment 10 Max Kanat-Alexander 2009-08-10 16:18:39 PDT
Created attachment 393654 [details] [diff] [review]
v4

Okay, in order to have all the functionality of jobqueue.pl, it has to be able to read its own pid file, and sometimes it has to run as a user who isn't root. With all of these requirements combined, I made a system that works. (It stores the PID in /var/run if you're root, and in Bugzilla's data/ directory if you're not.)

Also, I added an "install" and "uninstall" command to jobqueue.pl that automatically install and configure the system service for you on RHEL/Fedora.
Comment 11 Max Kanat-Alexander 2009-08-14 14:14:47 PDT
Comment on attachment 393654 [details] [diff] [review]
v4

Okay, wait. I realized that I can always store the PIDFILE in /var/run, and I just have to chown it to $USER.
Comment 12 Max Kanat-Alexander 2009-08-14 23:31:42 PDT
Created attachment 394629 [details] [diff] [review]
v5

Okay, here we go. :-) I'm pretty happy with this one.
Comment 13 David Lawrence [:dkl] 2009-08-15 21:30:31 PDT
(In reply to comment #12)
> Created an attachment (id=394629) [details]
> v5
> 
> Okay, here we go. :-) I'm pretty happy with this one.

I have just returned from a week off so I should be able to look at this on
Monday EDT.

Dave
Comment 14 David Lawrence [:dkl] 2009-08-17 10:34:39 PDT
Comment on attachment 394629 [details] [diff] [review]
v5

Sorry, I cannot get this patch to apply cleanly in my CVS checkout. Please create new patch.

Dave
Comment 15 Max Kanat-Alexander 2009-08-17 14:33:40 PDT
Comment on attachment 394629 [details] [diff] [review]
v5

It's dependent upon the patch from bug 509539.
Comment 16 David Lawrence [:dkl] 2009-09-04 13:03:42 PDT
Comment on attachment 394629 [details] [diff] [review]
v5

Ok, I have now had time to extensively test this and it looks good to me. I have put it through the different chkconfig tests, jobqueue.pl install/uninstall and played with the different options of /etc/sysconfig/bugzilla-queue. All functions worked as expected and queued email properly.

r=dkl
Comment 17 Max Kanat-Alexander 2009-09-04 13:20:46 PDT
Awesome, thank you. :-)
Comment 18 Max Kanat-Alexander 2009-09-04 14:24:27 PDT
tip:

Checking in jobqueue.pl;
/cvsroot/mozilla/webtools/bugzilla/jobqueue.pl,v  <--  jobqueue.pl
new revision: 1.4; previous revision: 1.3
done
Checking in Bugzilla/JobQueue/Runner.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/JobQueue/Runner.pm,v  <--  Runner.pm
new revision: 1.5; previous revision: 1.4
done
RCS file: /cvsroot/mozilla/webtools/bugzilla/contrib/bugzilla-queue,v
done
Checking in contrib/bugzilla-queue;
/cvsroot/mozilla/webtools/bugzilla/contrib/bugzilla-queue,v  <--  bugzilla-queue
initial revision: 1.1
done


3.4:

Checking in jobqueue.pl;
/cvsroot/mozilla/webtools/bugzilla/jobqueue.pl,v  <--  jobqueue.pl
new revision: 1.2.2.2; previous revision: 1.2.2.1
done
Checking in Bugzilla/JobQueue/Runner.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/JobQueue/Runner.pm,v  <--  Runner.pm
new revision: 1.2.2.3; previous revision: 1.2.2.2
done
Checking in contrib/bugzilla-queue;
/cvsroot/mozilla/webtools/bugzilla/contrib/bugzilla-queue,v  <--  bugzilla-queue
new revision: 1.1.2.2; previous revision: 1.1.2.1
done

Note You need to log in before you can comment on or make changes to this bug.