]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
init-ceph: wrap daemon startup with systemd-run when running under systemd
authorSage Weil <sage@redhat.com>
Wed, 16 Jul 2014 01:11:41 +0000 (18:11 -0700)
committerSage Weil <sage@redhat.com>
Wed, 16 Jul 2014 01:11:41 +0000 (18:11 -0700)
We want to make sure the daemon runs in its own systemd environment.  Check
for systemd as pid 1 and, when present, use systemd-run -r <cmd> to do
this.

Probably fixes #7627

Signed-off-by: Sage Weil <sage@redhat.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
Tested-by: Dan Mick <dan.mick@inktank.com>
src/init-ceph.in

index 86eb87ffc22f3fc1ca0d45aa2c038a46f5c178eb..12706c2a3bcf3c2de5cacf8783f38c0ef2a4153a 100644 (file)
@@ -44,6 +44,10 @@ test -f $LIBDIR/ceph_common.sh || exit 0
 
 EXIT_STATUS=0
 
+# detect systemd
+SYSTEMD=0
+grep -qs systemd /proc/1/comm && SYSTEMD=1
+
 signal_daemon() {
     name=$1
     daemon=$2
@@ -272,7 +276,11 @@ for name in $what; do
            [ -n "$wrap" ] && runmode="-f &" && runarg="-f"
            [ -n "$max_open_files" ] && files="ulimit -n $max_open_files;"
 
-           cmd="$files $wrap $cmd --cluster $cluster $runmode"
+           if [ $SYSTEMD -eq 1 ]; then
+               cmd="systemd-run -r bash -c '$files $cmd --cluster $cluster -f'"
+           else
+               cmd="$files $wrap $cmd --cluster $cluster $runmode"
+           fi
 
            if [ $dofsmount -eq 1 ] && [ -n "$fs_devs" ]; then
                get_conf pre_mount "true" "pre mount command"