[PATCH conductor] v2 RM 3317 - SysV init for conductor-delayed_job service
John Eckersberg
jeckersb at redhat.com
Tue Jun 19 13:28:13 UTC 2012
On Thu, 7 Jun 2012 10:38:51 -0700, Richard Su <rwsu at redhat.com> wrote:
> We support systems that are not systemd aware. Resurrected the old
> SysV init script to support those systems.
>
> Modified conductor spec file to install either the systemd or SysV
> init configuration files depending on what the os supports.
>
> v2 - updated spec file to use os version numbers instead of checking
> the existence of a directory to determine if systemd is available.
> ---
> aeolus-conductor.spec.in | 31 +++++++++++++++++-
> conf/conductor-delayed_job | 77 ++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 107 insertions(+), 1 deletions(-)
> create mode 100755 conf/conductor-delayed_job
>
> diff --git a/aeolus-conductor.spec.in b/aeolus-conductor.spec.in
> index 4c5aad5..41f7641 100644
> --- a/aeolus-conductor.spec.in
> +++ b/aeolus-conductor.spec.in
> @@ -9,6 +9,12 @@
> %global rubyabi 1.8
> %endif
>
> +%if 0%{?fedora} > 13 || 0%{?rhel} > 6
> +%global systemd 1
> +%else
> +%global systemd 0
> +%endif
> +
> Name: aeolus-conductor
> Version: @VERSION@
> Release: 0%{?dist}
> @@ -79,10 +85,12 @@ Requires: rubygem(thin) >= 1.2.5
> Requires(post): chkconfig
> Requires(preun): chkconfig
> Requires(preun): initscripts
> +%if %{systemd}
> Requires(post): systemd-units
> Requires(preun): systemd-units
> Requires(postun): systemd-units
> BuildRequires: systemd-units
> +%endif
>
> %description daemons
> The configuration and daemons necessary to run and proxy the Aeolus Conductor.
> @@ -157,7 +165,9 @@ getent passwd aeolus >/dev/null || \
> %{__mkdir} -p %{buildroot}%{app_root}
> %{__mkdir} -p %{buildroot}%{doc_root}
> %{__mkdir} -p %{buildroot}%{_initrddir}
> +%if %{systemd}
> %{__mkdir} -p %{buildroot}%{_unitdir}/systemd/system
> +%endif
> %{__mkdir} -p %{buildroot}%{_sysconfdir}/sysconfig
> %{__mkdir} -p %{buildroot}%{_sysconfdir}/httpd/conf.d
> %{__mkdir} -p %{buildroot}%{_sysconfdir}/logrotate.d
> @@ -271,7 +281,11 @@ done
> # copy over init scripts and various config
> %{__cp} conf/aeolus-conductor %{buildroot}%{_initrddir}
> %{__cp} conf/conductor-dbomatic %{buildroot}%{_initrddir}
> +%if %{systemd}
> %{__cp} conf/conductor-delayed_job.systemd %{buildroot}%{_unitdir}/conductor-delayed_job.service
> +%else
> +%{__cp} conf/conductor-delayed_job %{buildroot}%{_initrddir}
> +%endif
> %{__cp} conf/aeolus-conductor-httpd.conf %{buildroot}%{_sysconfdir}/httpd/conf.d/aeolus-conductor.conf
> %{__cp} conf/aeolus-conductor.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/aeolus-conductor
> %{__cp} conf/aeolus-conductor.sysconf %{buildroot}%{_sysconfdir}/sysconfig/aeolus-conductor
> @@ -333,19 +347,28 @@ if [ ! -d %{app_root}/app ]; then
> fi
>
> %post daemons
> +# Register the services
> +%if %{systemd}
> if [ $1 -eq 1 ] ; then
> # Initial installation
> /bin/systemctl daemon-reload >/dev/null 2>&1
> fi
> -# Register the services
> +%else
> +/sbin/chkconfig --add conductor-delayed_job
> +%endif
> /sbin/chkconfig --add aeolus-conductor
> /sbin/chkconfig --add conductor-dbomatic
>
> %preun daemons
> if [ $1 = 0 ]; then
> # Package removal, not upgrade
> + %if %{systemd}
> /bin/systemctl --no-reload disable conductor-delayed_job.service > /dev/null 2>&1
> /bin/systemctl stop conductor-delayed_job.service > /dev/null 2>&1
> + %else
> + /sbin/service conductor-delayed_job stop > /dev/null 2>&1
> + /sbin/chkconfig --del conductor-delayed_job
> + %endif
> /sbin/service aeolus-conductor stop > /dev/null 2>&1
> /sbin/chkconfig --del aeolus-conductor
> /sbin/service conductor-dbomatic stop > /dev/null 2>&1
> @@ -353,11 +376,13 @@ if [ $1 = 0 ]; then
> fi
>
> %postun daemons
> +#%if %{systemd}
> /bin/systemctl daemon-reload >/dev/null 2>&1 || :
> if [ $1 -ge 1 ] ; then
> # Package upgrade, not uninstall
> /bin/systemctl try-restart conductor-delayed_job.service >/dev/null 2>&1
> fi
> +#%endif
>
>
> %files
> @@ -391,7 +416,11 @@ fi
> %files daemons
> %{_initrddir}/aeolus-conductor
> %{_initrddir}/conductor-dbomatic
> +%if %{systemd}
> %{_unitdir}/conductor-delayed_job.service
> +%else
> +%{_initrddir}/conductor-delayed_job
> +%endif
> %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
> %config(noreplace) %{_sysconfdir}/sysconfig/aeolus-conductor
> %config(noreplace) %{_sysconfdir}/sysconfig/conductor-rails
> diff --git a/conf/conductor-delayed_job b/conf/conductor-delayed_job
> new file mode 100755
> index 0000000..6d2bdac
> --- /dev/null
> +++ b/conf/conductor-delayed_job
> @@ -0,0 +1,77 @@
> +#!/bin/bash
> +#
> +#
> +# conductor-delayed_job startup script for conductor-delayed_job
> +#
> +# chkconfig: - 99 01
> +# description: conductor-delayed_job is service for running conductor
> +# background jobs
> +
> +[ -r /etc/sysconfig/conductor-rails ] && . /etc/sysconfig/conductor-rails
> +
> +[ -r /etc/sysconfig/aeolus-conductor ] && . /etc/sysconfig/aeolus-conductor
> +
> +RAILS_ENV="${RAILS_ENV:-production}"
> +CONDUCTOR_DIR="${CONDUCTOR_DIR:-/usr/share/aeolus-conductor}"
> +AEOLUS_USER="${AEOLUS_USER:-aeolus}"
> +DJOB_LOCKFILE="${DJOB_LOCKFILE:-/var/lock/subsys/conductor-delayed_job}"
> +DJOB_PIDDIR="${DJOB_PIDDIR:-/var/run/aeolus-conductor/}"
> +
> +DJOB_PATH=$CONDUCTOR_DIR/script/
> +DJOB_PROG=delayed_job
> +DJOB_PIDFILE=$DJOB_PIDDIR/$DJOB_PROG.pid
> +
> +. /etc/init.d/functions
> +
> +start() {
> + echo -n "Starting conductor-delayed_job: "
> +
> + daemon --user=$AEOLUS_USER $DJOB_PATH/$DJOB_PROG start -n 2 --pid-dir=$DJOB_PIDDIR
> + RETVAL=$?
> + if [ $RETVAL -eq 0 ] && touch $DJOB_LOCKFILE ; then
> + echo_success
> + echo
> + else
> + echo_failure
> + echo
> + fi
> +}
> +
> +stop() {
> + echo -n "Shutting down conductor-delayed_job: "
> + $DJOB_PATH/$DJOB_PROG stop --pid-dir=$DJOB_PIDDIR
> + RETVAL=$?
> + if [ $RETVAL -eq 0 ] && rm -f $DJOB_LOCKFILE ; then
> + echo_success
> + echo
> + else
> + echo_failure
> + echo
> + fi
> +}
> +
> +case "$1" in
> + start)
> + start
> + ;;
> + stop)
> + stop
> + ;;
> + restart)
> + stop
> + start
> + ;;
> + status)
> + status -p $DJOB_PIDFILE $DJOB_PROG
> + RETVAL=$?
> + ;;
> + force-reload)
> + restart
> + ;;
> + *)
> + echo "Usage: conductor-delayed_job {start|stop|restart|status}"
> + exit 1
> + ;;
> +esac
> +
> +exit $RETVAL
> --
> 1.7.7.6
>
ACK, although I had to do terrible things to make master build on EL6
for smoketesting purposes. The spirit of the patch seems to work fine
though :)
More information about the aeolus-devel
mailing list