[supervisor] add native systemd support

Nils Philippsen nphilipp at fedoraproject.org
Tue Aug 2 14:16:07 UTC 2011


commit a88b550b2bd1a51c93267f43b06ec0ac79f50cf6
Author: Nils Philippsen <nils at redhat.com>
Date:   Tue Aug 2 16:15:43 2011 +0200

    add native systemd support

 supervisor.spec     |   49 ++++++++++++++++++++++++++++++---------
 supervisord.init    |   63 ---------------------------------------------------
 supervisord.service |    8 ++++++
 3 files changed, 46 insertions(+), 74 deletions(-)
---
diff --git a/supervisor.spec b/supervisor.spec
index 97bece1..3facba5 100644
--- a/supervisor.spec
+++ b/supervisor.spec
@@ -1,15 +1,16 @@
 %{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
+
 Summary:  A System for Allowing the Control of Process State on UNIX
 Name: supervisor
 Version: 3.0
 %define prever a10
-Release: 0.5%{?prever:.%{prever}}%{?dist}
+Release: 0.6%{?prever:.%{prever}}%{?dist}
 
 License: ZPLv2.1 and BSD and MIT
 Group: System Environment/Base
 URL: http://supervisord.org/
 Source0: http://pypi.python.org/packages/source/s/%{name}/%{name}-%{version}%{?prever}.tar.gz
-Source1: supervisord.init
+Source1: supervisord.service
 Source2: supervisord.conf
 Source3: supervisor.logrotate
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
@@ -19,8 +20,12 @@ BuildRequires: python-setuptools
 
 Requires: python-meld3 >= 0.6.5
 Requires: python-setuptools
-Requires(preun): /sbin/service, /sbin/chkconfig
-Requires(postun): /sbin/service, /sbin/chkconfig
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+# These should actually be Requires(triggerun) but that doesn't work
+Requires(post): systemd-sysv
+Requires(post): chkconfig
 
 
 %description
@@ -39,10 +44,10 @@ rm -rf %{buildroot}
 mkdir -p %{buildroot}/%{_sysconfdir}
 mkdir -p %{buildroot}/%{_sysconfdir}/supervisord.d
 mkdir -p %{buildroot}/%{_sysconfdir}/logrotate.d/
-mkdir -p %{buildroot}/%{_initrddir}
+mkdir -p %{buildroot}/lib/systemd/system
 mkdir -p %{buildroot}/%{_localstatedir}/log/%{name}
 chmod 770 %{buildroot}/%{_localstatedir}/log/%{name}
-install -p -m 755 %{SOURCE1} %{buildroot}/%{_initrddir}/supervisord
+install -p -m 644 %{SOURCE1} %{buildroot}/lib/systemd/system/supervisord.service
 install -p -m 644 %{SOURCE2} %{buildroot}/%{_sysconfdir}/supervisord.conf
 install -p -m 644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/logrotate.d/supervisor
 sed -i s'/^#!.*//' $( find %{buildroot}/%{python_sitelib}/supervisor/ -type f)
@@ -54,19 +59,38 @@ rm -f %{buildroot}%{_prefix}/doc/*.txt
 rm -rf %{buildroot}
 
 %post
-/sbin/chkconfig --add %{name}d || :
+if [ $1 -eq 1 ] ; then
+    # Initial installation
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
 
 %preun
-if [ $1 = 0 ]; then
-    /sbin/service supervisord stop > /dev/null 2>&1 || :
-    /sbin/chkconfig --del %{name}d || :
+if [ $1 -eq 0 ] ; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable supervisord.service > /dev/null 2>&1 || :
+    /bin/systemctl stop supervisord.service > /dev/null 2>&1 || :
 fi
 
+%postun
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+# Don't restart supervisord here, we don't want its children to be restarted
+# when the supervisor package is upgraded. Admins need to manually reload or
+# restart supervisord.service.
+
+%triggerun -- supervisor < supervisor-3.0-0.6.a10
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply httpd
+# to migrate them to systemd targets
+%{_bindir}/systemd-sysv-convert --save supervisord > /dev/null 2>&1 || :
+
+# Run this here because the SysV package being removed won't do it
+/sbin/chkconfig --del supervisord >/dev/null 2>&1 || :
+
 %files
 %defattr(-,root,root,-)
 %doc README.txt LICENSES.txt TODO.txt CHANGES.txt COPYRIGHT.txt
 %dir %{_localstatedir}/log/%{name}
-%{_initrddir}/supervisord
+/lib/systemd/system/supervisord.service
 %{python_sitelib}/*
 %{_bindir}/supervisor*
 %{_bindir}/echo_supervisord_conf
@@ -77,6 +101,9 @@ fi
 %config(noreplace) %{_sysconfdir}/logrotate.d/supervisor
 
 %changelog
+* Tue Aug 02 2011 Nils Philippsen <nils at redhat.com> - 3.0-0.6.a10
+- add native systemd support
+
 * Mon Aug 01 2011 Nils Philippsen <nils at redhat.com> - 3.0-0.5.a10
 - require python-setuptools (#725191)
 
diff --git a/supervisord.service b/supervisord.service
new file mode 100644
index 0000000..dc27bef
--- /dev/null
+++ b/supervisord.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Process Monitoring and Control Daemon
+After=rc-local.service
+
+[Service]
+Type=forking
+ExecStart=/usr/bin/supervisord
+SysVStartPriority=99


More information about the scm-commits mailing list