diff --git a/.gitignore b/.gitignore index 8654099..78ed894 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ beanstalkd-1.4.6.tar.gz +*~ diff --git a/beanstalkd.init b/beanstalkd.init deleted file mode 100644 index de399a3..0000000 --- a/beanstalkd.init +++ /dev/null @@ -1,136 +0,0 @@ -#!/bin/sh -# -# beanstalkd - a simple, fast workqueue service -# -# chkconfig: - 57 47 -# description: a simple, fast workqueue service -# processname: beanstalkd -# config: /etc/sysconfig/beanstalkd -# - -### BEGIN INIT INFO -# Provides: beanstalkd -# Required-Start: $local_fs $network $remote_fs -# Required-Stop: $local_fs $network $remote_fs -# Default-Stop: 0 1 2 6 -# Short-Description: start and stop beanstalkd -# Description: a simple, fast work-queue service -### END INIT INFO - -# Source function library. -. /etc/rc.d/init.d/functions - -# Source networking configuration. -. /etc/sysconfig/network - -# Check that networking is up. -[ "$NETWORKING" = "no" ] && exit -exec="/usr/bin/beanstalkd" -prog=$(basename $exec) - -# default options, overruled by items in sysconfig -BEANSTALKD_ADDR=0.0.0.0 -BEANSTALKD_PORT=11300 -BEANSTALKD_USER=beanstalkd - -[ -e /etc/sysconfig/beanstalkd ] && . /etc/sysconfig/beanstalkd - -lockfile=/var/lock/subsys/beanstalkd - -start() { - [ -x $exec ] || exit 5 - echo -n $"Starting $prog: " - # if not running, start it up here, usually something like "daemon $exec" - options="-l ${BEANSTALKD_ADDR} -p ${BEANSTALKD_PORT} -u ${BEANSTALKD_USER}" - if [ "${BEANSTALKD_MAX_JOB_SIZE}" != "" ]; then - options="${options} -z ${BEANSTALKD_MAX_JOB_SIZE}" - fi - - if [ "${BEANSTALKD_BINLOG_DIR}" != "" ]; then - if [ ! -d "${BEANSTALKD_BINLOG_DIR}" ]; then - echo "Creating binlog directory (${BEANSTALKD_BINLOG_DIR})" - mkdir -p ${BEANSTALKD_BINLOG_DIR} && chown ${BEANSTALKD_USER}:${BEANSTALKD_USER} ${BEANSTALKD_BINLOG_DIR} - fi - options="${options} -b ${BEANSTALKD_BINLOG_DIR}" - if [ "${BEANSTALKD_BINLOG_FSYNC_PERIOD}" != "" ]; then - options="${options} -f ${BEANSTALKD_BINLOG_FSYNC_PERIOD}" - else - options="${options} -F" - fi - if [ "${BEANSTALKD_BINLOG_SIZE}" != "" ]; then - options="${options} -s ${BEANSTALKD_BINLOG_SIZE}" - fi - fi - - daemon $exec -d $options - retval=$? - echo - [ $retval -eq 0 ] && touch $lockfile - return $retval -} - -stop() { - echo -n $"Stopping $prog: " - # stop it here, often "killproc $prog" - killproc $prog -INT - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval -} - -restart() { - stop - start -} - -reload() { - restart -} - -force_reload() { - restart -} - -rh_status() { - # run checks to determine if the service is running or use generic status - status $prog -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - - -case "$1" in - start) - rh_status_q && exit 0 - $1 - ;; - stop) - rh_status_q || exit 0 - $1 - ;; - restart) - $1 - ;; - reload) - rh_status_q || exit 7 - $1 - ;; - force-reload) - force_reload - ;; - status) - rh_status - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - exit 2 -esac -exit $? - diff --git a/beanstalkd.service b/beanstalkd.service new file mode 100644 index 0000000..3dbe5ed --- /dev/null +++ b/beanstalkd.service @@ -0,0 +1,13 @@ +[Unit] +Description=Beanstalkd Fast Workqueue Service +After=network.target + +[Service] +User=beanstalkd +Type=simple +EnvironmentFile=-/etc/sysconfig/beanstalkd +ExecStart=/usr/bin/beanstalkd $ADDR $PORT $USER $MAX_JOB_SIZE $BINLOG_DIR $BINLOG_SIZE $BINLOG_FSYNC_PERIOD +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/beanstalkd.spec b/beanstalkd.spec index 484fa13..18523fb 100644 --- a/beanstalkd.spec +++ b/beanstalkd.spec @@ -5,25 +5,25 @@ Name: beanstalkd Version: 1.4.6 -Release: 5%{?dist} +Release: 6%{?dist} Summary: A simple, fast work-queue service Group: System Environment/Daemons License: GPLv3+ -URL: http://xph.us/software/%{name}/ -Source0: http://xph.us/dist/%{name}/%{name}-%{version}.tar.gz -Source1: %{name}.init +URL: http://kr.github.com/%{name}/ +Source0: https://github.com/downloads/kr/%{name}/%{name}-%{version}.tar.gz +Source1: %{name}.service Source2: %{name}.sysconfig BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: libevent-devel +BuildRequires: libevent-devel +BuildRequires: systemd-units -Requires(pre): %{_sbindir}/useradd -Requires(pre): %{_sbindir}/groupadd -Requires(post): chkconfig -Requires(preun): chkconfig -Requires(preun): initscripts -Requires(postun): initscripts + +Requires(pre): shadow-utils +Requires(post): systemd-units +Requires(preun): systemd-units +Requires(postun): systemd-units # fixes dprintf source conflict. This is patch from upstream's git repository. # A new release has not been made that includes this patch @@ -55,7 +55,7 @@ make %{?_smp_mflags} rm -rf $RPM_BUILD_ROOT make install-man1 DESTDIR=$RPM_BUILD_ROOT make install-exec-am DESTDIR=$RPM_BUILD_ROOT -%{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{name} +%{__install} -p -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service %{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/%{name} %{__install} -d -m 0755 %{buildroot}%{beanstalkd_home} %{__install} -d -m 0755 %{buildroot}%{beanstalkd_binlogdir} @@ -65,13 +65,14 @@ make install-exec-am DESTDIR=$RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT %pre -%{_sbindir}/groupadd -f -r %{beanstalkd_group} -%{_sbindir}/useradd -r -m -c "beanstalkd user" -s /bin/false \ - -d %{beanstalkd_home} -g %{beanstalkd_group} %{beanstalkd_user} 2>/dev/null || : +getent group %{beanstalkd_group} >/dev/null || groupadd -r %{beanstalkd_group} +getent passwd %{beanstalkd_user} >/dev/null || \ + useradd -r -g %{beanstalkd_user} -d %{beanstalkd_home} -s /sbin/nologin \ + -c "beanstalkd user" %{beanstalkd_user} +exit 0 -%post -/sbin/chkconfig --add %{name} +%post # make the binlog dir after installation, this is so SELinux does not complain # about the init script creating the binlog directory # Bug 558310 @@ -81,29 +82,44 @@ if [ -d %{beanstalkd_home} ]; then %{beanstalkd_binlogdir} fi +if [ $1 -eq 1 ] ; then + # Initial installation + /bin/systemctl daemon-reload >/dev/null 2>&1 || : +fi + + %preun -if [ $1 = 0 ]; then - /sbin/service %{name} stop >/dev/null 2>&1 - /sbin/chkconfig --del %{name} +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + /bin/systemctl --no-reload disable %{name}.service > /dev/null 2>&1 || : + /bin/systemctl stop %{name}.service > /dev/null 2>&1 || : fi %postun -if [ "$1" -ge "1" ]; then - /sbin/service %{name} condrestart > /dev/null 2>&1 || : +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || : fi + %files %defattr(-,root,root,-) %doc README README-DEVELOPERS README-TESTS COPYING doc/protocol.txt -%{_initrddir}/%{name} +%{_unitdir}/%{name}.service %{_bindir}/%{name} %{_mandir}/man1/%{name}.1.gz %config(noreplace) %{_sysconfdir}/sysconfig/%{name} -%ghost %attr(0755,%{beanstalkd_user},%{beanstalkd_group}) %dir %{beanstalkd_home} +%attr(0755,%{beanstalkd_user},%{beanstalkd_group}) %dir %{beanstalkd_home} %ghost %attr(0755,%{beanstalkd_user},%{beanstalkd_group}) %dir %{beanstalkd_binlogdir} %changelog +* Sun Feb 19 2012 Jeremy Hinegardner - 1.4.6-6 +- Add systemd config Bug #754490 +- fix user/group creation to be in line with packaging standards +- fix Source URL + * Thu Jan 12 2012 Fedora Release Engineering - 1.4.6-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild diff --git a/beanstalkd.sysconfig b/beanstalkd.sysconfig index 3024e52..e0bb152 100644 --- a/beanstalkd.sysconfig +++ b/beanstalkd.sysconfig @@ -1,27 +1,29 @@ # System configuration for the beanstalkd daemon -# Available options correspond to the options to the -# beanstalkd commandline. +# +# beanstalkd commandline options +# -BEANSTALKD_ADDR=0.0.0.0 -BEANSTALKD_PORT=11300 -BEANSTALKD_USER=beanstalkd +ADDR=-l 0.0.0.0 +PORT=-p 11300 +USER=-u beanstalkd # Job size is left to the default. Uncomment and set it # to a value to have it take affect. -#BEANSTALKD_MAX_JOB_SIZE=65535 +#MAX_JOB_SIZE=-z 65535 # Using the binlog is off by default. # # The direcory to house the binlog. -#BEANSTALKD_BINLOG_DIR=/var/lib/beanstalkd/binlog +#BINLOG_DIR=-b /var/lib/beanstalkd/binlog # # fsync the binlog at most once every N milliseconds. # setting this to 0 means 'always fsync'. If this is unset, # and the binlog is used, then no explicit fsync is ever # performed. That is, the -F option is used. -#BEANSTALKD_BINLOG_FSYNC_PERIOD= +#BINLOG_FSYNC_PERIOD=-f some-value # # The size of each binlog file. This is rounded # up to the nearest 512 byte boundary. -#BEANSTALKD_BINLOG_SIZE=10485760 +#BINLOG_SIZE=-s 10485760 +