From 3e0d9800767018625f0e7d797c812aa44c426dab Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 15 Jul 2014 18:11:41 -0700 Subject: [PATCH] init-ceph: wrap daemon startup with systemd-run when running under systemd 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 to do this. Probably fixes #7627 Signed-off-by: Sage Weil Reviewed-by: Dan Mick Tested-by: Dan Mick --- src/init-ceph.in | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/init-ceph.in b/src/init-ceph.in index 86eb87ffc22f3..12706c2a3bcf3 100644 --- a/src/init-ceph.in +++ b/src/init-ceph.in @@ -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" -- 2.39.5