]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
init-radosgw: unify init-radosgw[.sysv]
authorSage Weil <sage@redhat.com>
Thu, 7 May 2015 22:39:22 +0000 (15:39 -0700)
committerSage Weil <sage@redhat.com>
Thu, 14 May 2015 16:50:09 +0000 (09:50 -0700)
Signed-off-by: Sage Weil <sage@redhat.com>
src/init-radosgw

index c0a0bd1ad791889cf6fb4d4a15defc6fca585106..149d6d12e4c74a73479b8d77cefa10f5006294f8 100644 (file)
 
 PATH=/sbin:/bin:/usr/bin
 
-. /lib/lsb/init-functions
+if [ -x /sbin/start-stop-daemon ]; then
+    DEBIAN=1
+    . /lib/lsb/init-functions
+else
+    . /etc/rc.d/init.d/functions
+    DEBIAN=0
+
+    # detect systemd, also check whether the systemd-run binary exists
+    SYSTEMD_RUN=$(which systemd-run 2>/dev/null)
+    grep -qs systemd /proc/1/comm || SYSTEMD_RUN=""
+fi
 
 daemon_is_running() {
     daemon=$1
@@ -89,14 +99,24 @@ case "$1" in
             fi
 
             echo "Starting $name..."
-            start-stop-daemon --start -u $user -x $RADOSGW -- -n $name
+           if [ $DEBIAN -eq 1 ]; then
+               start-stop-daemon --start -u $user -x $RADOSGW -- -n $name
+           elif [ -n "$SYSTEMD_RUN" ]; then
+                $SYSTEMD_RUN -r sudo -u "$user" bash -c "ulimit -n 32768; $RADOSGW -n $name"
+            else
+               ulimit -n 32768
+                daemon --user="$user" "$RADOSGW -n $name"
+            fi
         done
-        daemon_is_running $RADOSGW
         ;;
     reload)
         echo "Reloading $name..."
-        start-stop-daemon --stop --signal HUP -x $RADOSGW --oknodo
-        ;;
+       if [ $DEBIAN -eq 1 ]; then
+            start-stop-daemon --stop --signal HUP -x $RADOSGW --oknodo
+       else
+            killproc $RADOSGW -SIGHUP
+       fi
+       ;;
     restart|force-reload)
         $0 stop
         $0 start
@@ -109,8 +129,16 @@ case "$1" in
           if [ $t -gt $timeout ]; then timeout=$t; fi
         done
 
-        if [ $timeout -gt 0 ]; then TIMEOUT="-R $timeout"; fi
-        start-stop-daemon --stop -x $RADOSGW --oknodo $TIMEOUT
+       if [ $DEBIAN -eq 1 ]; then
+            if [ $timeout -gt 0 ]; then TIMEOUT="-R $timeout"; fi
+            start-stop-daemon --stop -x $RADOSGW --oknodo $TIMEOUT
+       else
+           killproc $RADOSGW
+           while pidof $RADOSGW >/dev/null && [ $timeout -gt 0 ] ; do
+               sleep 1
+               timeout=$(($timeout - 1))
+            done
+       fi
         ;;
     status)
         daemon_is_running $RADOSGW