]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
better systemd support 3044/head
authorOwen Synge <osynge@suse.com>
Mon, 1 Dec 2014 13:32:48 +0000 (14:32 +0100)
committerOwen Synge <osynge@suse.com>
Mon, 1 Dec 2014 13:45:31 +0000 (14:45 +0100)
Added ceph.target
Made ceph-mds, ceph-mon, ceph-osd services part of ceph.target
Made ceph-mds, ceph-mon, ceph-osd services require partitions to be available.
Added ceph init script with sysV like behaviour.

Provided by Tim Serong tserong@suse.com and Owen Synge osynge@suse.com

Signed-off-by: Owen Synge <osynge@suse.com>
systemd/ceph [new file with mode: 0644]
systemd/ceph-mds@.service
systemd/ceph-mon@.service
systemd/ceph-osd@.service
systemd/ceph.target [new file with mode: 0644]

diff --git a/systemd/ceph b/systemd/ceph
new file mode 100644 (file)
index 0000000..e60dec6
--- /dev/null
@@ -0,0 +1,66 @@
+#! /bin/bash
+
+### BEGIN INIT INFO
+# Provides:       ceph ceph-mon ceph-osd
+# Required-Start: $network $remote_fs
+# Required-Stop:  $network $remote_fs
+# Should-Start: network-remotefs
+# Should-Stop: network-remotefs
+# Default-Start:  3 5
+# Default-Stop:   0 1 2 6
+# Short-Description: Ceph is a distributed object, and block, storage platform
+# Description:    Ceph is a distributed object, block, and file storage platform
+### END INIT INFO
+
+SYSTEMD_NO_WRAP=1 . /etc/rc.status
+rc_reset
+
+action=$1 ; shift
+cluster="ceph"
+config=$1 ; shift
+
+# Shared variables by many actions
+dir_mon="/var/lib/ceph/mon/"
+dir_osd="/var/lib/ceph/osd/"
+if test -d ${dir_mon} ; then
+lmon=`ls ${dir_mon} | grep ${cluster}`
+fi
+if test -d ${dir_osd} ; then
+losd=`ls ${dir_osd} | grep ${cluster}`
+fi
+prefix="${cluster}-"
+
+if test -n "$config" ; then
+       systemctl "${action}" "ceph-mon@${config}.service"
+else
+       case $action in
+    start | stop | status | enable | disable | restart | is-active | is-failed | show | kill | reset-failed  )
+        n=0
+        if test -n ${lmon} ; then
+            for s in ${lmon#=${prefix}} ; do
+                systemctl "${action}" ceph-mon@${s#$prefix}.service
+                rc_check
+                ((++n))
+            done
+        fi
+        if test -n ${lmon} ; then
+            for s in ${losd#=${prefix}} ; do
+                systemctl "${action}" ceph-osd@${s#$prefix}.service
+                rc_check
+                ((++n))
+            done
+        fi
+        if test $n -gt 0 ; then
+                       rc_status
+               else
+                       rc_status -u
+               fi
+    ;;
+       *)
+               echo "Invalid paramter : $action"
+        echo "Valid paramters  : start | stop | status | enable | disable | restart | is-active | is-failed | show | kill | reset-failed"
+       ;;
+       esac
+fi
+rc_exit
+
index 1cb3a8652d8429084b403d99e745de108a766937..22a787d60b4156f7f3f25ce99baf48fa0144b7fb 100644 (file)
@@ -1,7 +1,8 @@
 [Unit]
 Description=Ceph metadata server daemon
-After=network-online.target
-Wants=network-online.target
+After=network-online.target local-fs.target
+Wants=network-online.target local-fs.target
+PartOf=ceph.target
 
 [Service]
 EnvironmentFile=-/etc/sysconfig/ceph
@@ -9,4 +10,4 @@ Environment=CLUSTER=ceph
 ExecStart=/usr/bin/ceph-mds -f --cluster ${CLUSTER} --id %i
 
 [Install]
-WantedBy=multi-user.target
+WantedBy=ceph.target
index ccd90899f1ff948be0d05f8de2e537e5b1744c95..c3d260989d7f98e8b6f295ffd68c029a44cb5879 100644 (file)
@@ -7,8 +7,9 @@ Wants=network-online.target
 #   http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget
 # these can be removed once ceph-mon will dynamically change network
 # configuration.
-After=network-online.target
-Wants=network-online.target
+After=network-online.target local-fs.target
+Wants=network-online.target local-fs.target
+PartOf=ceph.target
 
 [Service]
 EnvironmentFile=-/etc/sysconfig/ceph
@@ -16,4 +17,4 @@ Environment=CLUSTER=ceph
 ExecStart=/usr/bin/ceph-mon -f --cluster ${CLUSTER} --id %i
 
 [Install]
-WantedBy=multi-user.target
+WantedBy=ceph.target
index e8cbcdad9af48d24c5db4abf975f1463783b70f5..edb24ad4b1f99f84f1477f458f251787c1e907df 100644 (file)
@@ -1,7 +1,8 @@
 [Unit]
 Description=Ceph object storage daemon
-After=network-online.target
-Wants=network-online.target
+After=network-online.target local-fs.target
+Wants=network-online.target local-fs.target
+PartOf=ceph.target
 
 [Service]
 EnvironmentFile=-/etc/sysconfig/ceph
@@ -10,4 +11,4 @@ ExecStart=/usr/bin/ceph-osd -f --cluster ${CLUSTER} --id %i
 ExecStartPre=/usr/libexec/ceph/ceph-osd-prestart.sh --cluster ${CLUSTER} --id %i
 
 [Install]
-WantedBy=multi-user.target
+WantedBy=ceph.target
diff --git a/systemd/ceph.target b/systemd/ceph.target
new file mode 100644 (file)
index 0000000..60734ba
--- /dev/null
@@ -0,0 +1,4 @@
+[Unit]
+Description=ceph target allowing to start/stop all ceph*@.service instances at once
+[Install]
+WantedBy=multi-user.target