commit 3fb19a748bdc0916831a514fb8a59d4db535f3b3
Author: Jacek Konieczny <j.koniec...@eggsoft.pl>
Date:   Fri Nov 2 15:29:55 2012 +0100

    systemd support added (including multiple instances)

 mongod@.service | 14 ++++++++++++++
 mongodb.spec    | 28 +++++++++++++++++++++++++---
 2 files changed, 39 insertions(+), 3 deletions(-)
---
diff --git a/mongodb.spec b/mongodb.spec
index 2acb4cd..50d71cf 100644
--- a/mongodb.spec
+++ b/mongodb.spec
@@ -5,7 +5,7 @@ Summary:        MongoDB client shell and tools
 Summary(pl.UTF-8):     Powłoka kliencka i narzędzia dla bazy danych MongoDB
 Name:          mongodb
 Version:       2.2.0
-Release:       1
+Release:       1.1
 License:       AGPL v3
 Group:         Applications/Databases
 Source0:       http://downloads.mongodb.org/src/%{name}-src-r%{version}.tar.gz
@@ -13,6 +13,7 @@ Source0:      
http://downloads.mongodb.org/src/%{name}-src-r%{version}.tar.gz
 Source1:       %{name}.logrotate
 Source2:       %{name}.init
 Source3:       mongod-default.conf
+Source4:       mongod@.service
 Patch0:                %{name}-cflags.patch
 Patch1:                %{name}-system-libs.patch
 Patch2:                boost-1.50.patch
@@ -27,7 +28,7 @@ BuildRequires:        libtcmalloc-devel
 BuildRequires: pcre-cxx-devel
 BuildRequires: pcre-devel >= 8.30
 BuildRequires: readline-devel
-BuildRequires: rpmbuild(macros) >= 1.228
+BuildRequires: rpmbuild(macros) >= 1.644
 BuildRequires: scons >= 1.2
 BuildRequires: sed >= 4.0
 BuildRequires: snappy-devel
@@ -111,6 +112,7 @@ Summary:    MongoDB server, sharding server, and support 
scripts
 Summary(pl.UTF-8):     Serwer MongoDB, serwer dzielący oraz skrypty pomocnicze
 Group:         Applications/Databases
 Requires:      %{name} = %{version}-%{release}
+Requires:      systemd-units >= 38
 Requires(post,preun):  /sbin/chkconfig
 Requires(postun):      /usr/sbin/groupdel
 Requires(postun):      /usr/sbin/userdel
@@ -163,7 +165,8 @@ find -type f -executable | xargs chmod a-x
 rm -rf $RPM_BUILD_ROOT
 install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{_mandir}/man1} \
        $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,sysconfig,mongod} \
-       $RPM_BUILD_ROOT%{_var}/{lib,log{,/archive}}/mongo
+       $RPM_BUILD_ROOT%{_var}/{lib,log{,/archive}}/mongo \
+       $RPM_BUILD_ROOT%{systemdunitdir}
 
 # XXX: scons is so great, recompiles everything here!
 %scons install \
@@ -180,6 +183,10 @@ cp -p rpm/mongod.sysconfig 
$RPM_BUILD_ROOT/etc/sysconfig/mongod
 install %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/mongod/default.conf
 cp -p debian/*.1 $RPM_BUILD_ROOT%{_mandir}/man1
 
+# mask out the LSB service
+ln -s /dev/null $RPM_BUILD_ROOT%{systemdunitdir}/mongod.service
+install %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/mongod@.service
+
 touch $RPM_BUILD_ROOT%{_var}/log/mongo/mongod.log
 
 # for some reason these are installed twice, remove unwanted copies
@@ -200,11 +207,23 @@ rm -rf $RPM_BUILD_ROOT
 %post server
 /sbin/chkconfig --add mongod
 %service mongod restart
+# our systemd macros cannot handle template (multi-instance) units yet
+export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog
+/bin/systemd_booted && /bin/systemctl --quiet daemon-reload || :
+if [ $1 -eq 1 ]; then
+       /bin/systemctl --quiet enable mongod@.service || : 
+       /bin/systemd_booted && echo 'Run "/bin/systemctl start 
mongod@default.service" to start mongod.' || :
+else
+       /bin/systemd_booted && /bin/systemctl --quiet try-restart 
mongod@default.service || :
+fi
 
 %preun server
 if [ "$1" = "0" ]; then
        %service -q mongod stop
        /sbin/chkconfig --del mongod
+       export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog
+       /bin/systemd_booted && /bin/systemctl --quiet stop 
mongod@default.service || :
+       /bin/systemctl --quiet disable mongod@.service || :
 fi
 
 %postun server
@@ -212,6 +231,7 @@ if [ "$1" = "0" ]; then
        %userremove mongod
        %groupremove mongod
 fi
+%systemd_reload
 
 %triggerpostun server -- %{name}-server < 2.0.6-3
 if [ -f %{_sysconfdir}/mongod.conf.rpmsave ] ; then
@@ -276,3 +296,5 @@ fi
 %attr(775,root,mongod) %dir %{_var}/log/mongo
 %attr(775,root,mongod) %dir %{_var}/log/archive/mongo
 %attr(640,mongod,mongod) %config(noreplace) %verify(not md5 mtime size) 
%{_var}/log/mongo/mongod.log
+%{systemdunitdir}/mongod.service
+%{systemdunitdir}/mongod@.service
diff --git a/mongod@.service b/mongod@.service
new file mode 100644
index 0000000..d02a04e
--- /dev/null
+++ b/mongod@.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=the Mongo Daemon, '%i' instance
+After=syslog.target network.target
+
+[Service]
+Type=simple
+EnvironmentFile=-/etc/sysconfig/mongod
+ExecStartPre=/bin/sh -c "if grep -q '^[ \t]*fork\>' /etc/mongod/%i.conf ; then 
echo there must be no 'fork' in /etc/mongod/%i.conf >&2 ; exit 1 ; fi"
+ExecStart=/usr/bin/mongod --config /etc/mongod/%i.conf
+User=mongod
+Group=mongod
+
+[Install]
+Alias=multi-user.target.wants/mongod@default.service
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/mongodb.git/commitdiff/29f5f92cc25ab9c871fdd64a63d6835e86ffe576

_______________________________________________
pld-cvs-commit mailing list
pld-cvs-commit@lists.pld-linux.org
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to