]> git-server-git.apps.pok.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:14:59 +0000 (18:14 -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>
(cherry picked from commit 3e0d9800767018625f0e7d797c812aa44c426dab)

src/init-ceph.in

index 1effb564543572a088cb10d56494c3f5d5c2d260..95723b04ae8ac4943488ec8ae5c880a4fee05334 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"