From 150d13883c44b0a7e56395b614725fa241b761a05c18e15a79cb838db9a10e08 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Thu, 4 Apr 2013 09:48:47 +0000 Subject: [PATCH] Accepting request 162573 from home:dirkmueller:branches:network:messaging:amqp ------------------------------------------------------------------ - Change init script to properly daemonize (patch by jdsn) (bnc#807540) - Added systemd .service file OBS-URL: https://build.opensuse.org/request/show/162573 OBS-URL: https://build.opensuse.org/package/show/network:messaging:amqp/rabbitmq-server?expand=0&rev=16 --- rabbitmq-server.changes | 10 ++++++++++ rabbitmq-server.init | 4 ++-- rabbitmq-server.service | 17 +++++++++++++++++ rabbitmq-server.spec | 26 +++++++++++++++++++++++++- 4 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 rabbitmq-server.service diff --git a/rabbitmq-server.changes b/rabbitmq-server.changes index e11f867..a7a270f 100644 --- a/rabbitmq-server.changes +++ b/rabbitmq-server.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------ +Wed Apr 3 12:00:36 UTC 2013 - dmueller@suse.com + +- Change init script to properly daemonize (patch by jdsn) (bnc#807540) + +------------------------------------------------------------------- +Sun Mar 17 10:04:09 UTC 2013 - matwey.kornilov@gmail.com + +- Added systemd .service file + ------------------------------------------------------------------- Wed Mar 13 11:28:33 CET 2013 - berendt@b1-systems.de diff --git a/rabbitmq-server.init b/rabbitmq-server.init index c2fcc96..1ab8114 100644 --- a/rabbitmq-server.init +++ b/rabbitmq-server.init @@ -53,8 +53,8 @@ start_rabbitmq () { if [ $? -eq 0 ] ; then return 0 else - setsid sh -c "RABBITMQ_PID_FILE=$PID_FILE $DAEMON > \ - ${INIT_LOG_DIR}/startup_log 2> ${INIT_LOG_DIR}/startup_err" & + export RABBITMQ_PID_FILE=$PID_FILE + startproc -l ${INIT_LOG_DIR}/startup_log -p $PID_FILE $DAEMON $CONTROL wait $PID_FILE >/dev/null 2>&1 rc=$? case "$rc" in diff --git a/rabbitmq-server.service b/rabbitmq-server.service new file mode 100644 index 0000000..3f1e416 --- /dev/null +++ b/rabbitmq-server.service @@ -0,0 +1,17 @@ +[Unit] +Description=RabbitMQ broker +After=syslog.target network.target + +[Service] +Type=simple +User=rabbitmq +Group=rabbitmq +Environment=RABBITMQ_PID_FILE=/var/run/rabbitmq/pid +WorkingDirectory=/var/lib/rabbitmq +ExecStart=/usr/sbin/rabbitmq-server +ExecStartPost=/usr/sbin/rabbitmqctl wait /var/run/rabbitmq/pid +ExecStop=/usr/sbin/rabbitmqctl stop +ExecStopPost=/usr/bin/rm /var/run/rabbitmq/pid + +[Install] +WantedBy=multi-user.target diff --git a/rabbitmq-server.spec b/rabbitmq-server.spec index b13536d..3a3f0ff 100644 --- a/rabbitmq-server.spec +++ b/rabbitmq-server.spec @@ -1,7 +1,7 @@ # # spec file for package rabbitmq-server # -# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -37,6 +37,7 @@ Source2: rabbitmq-script-wrapper Source3: rabbitmq-server.logrotate Source4: rabbitmq-server.ocf Source5: rabbitmq-server.sysconfig +Source6: rabbitmq-server.service Patch0: no-nmap.patch Patch1: no-remove-common.patch BuildRequires: erlang @@ -57,6 +58,11 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build Requires(pre): pwdutils Requires(pre): %fillup_prereq Requires(pre): %insserv_prereq +%if 0%{?suse_version} > 1140 +BuildRequires: systemd +%{?systemd_requires} +%define have_systemd 1 +%endif # Do not use noarch since the Erlang packaging does not really allow that #BuildArch: noarch @@ -111,6 +117,9 @@ mkdir -p %{buildroot}%{_sbindir} ln -sf %{_initddir}/rabbitmq-server %{buildroot}%{_sbindir}/rcrabbitmq-server mkdir -p %{buildroot}%{_localstatedir}/adm/fillup-templates/ install -p -D -m 644 %{SOURCE5} %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.rabbitmq-server +%if 0%{?have_systemd} +install -p -D -m 644 %{SOURCE6} %{buildroot}%{_unitdir}/%{name}.service +%endif # Install wrapper scripts %define _rabbit_wrapper %{_builddir}/`basename %{SOURCE2}` @@ -155,17 +164,29 @@ getent passwd rabbitmq >/dev/null || useradd -r -g rabbitmq \ -d %{_localstatedir}/lib/rabbitmq \ -s /sbin/nologin \ -c "user for RabbitMQ messaging server" rabbitmq +%if 0%{?have_systemd} +%service_add_pre %{name}.service +%endif exit 0 %post %fillup_and_insserv rabbitmq-server +%if 0%{?have_systemd} +%service_add_post %{name}.service +%endif %preun %stop_on_removal rabbitmq-server +%if 0%{?have_systemd} +%service_del_preun %{name}.service +%endif %postun %restart_on_update rabbitmq-server %insserv_cleanup +%if 0%{?have_systemd} +%service_del_postun %{name}.service +%endif %files -f ../filelist.%{name}.rpm %defattr(-,root,root,-) @@ -178,6 +199,9 @@ exit 0 %{_rabbit_erllibdir} %{_initddir}/rabbitmq-server %{_sbindir}/rcrabbitmq-server +%if 0%{?have_systemd} +%{_unitdir}/%{name}.service +%endif %dir /usr/lib/ocf %dir /usr/lib/ocf/resource.d %dir /usr/lib/ocf/resource.d/rabbitmq