]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
init-ceph: do already running check early to avoid extra work
authorSage Weil <sage@newdream.net>
Wed, 17 Mar 2010 16:46:02 +0000 (09:46 -0700)
committerSage Weil <sage@newdream.net>
Thu, 18 Mar 2010 18:35:58 +0000 (11:35 -0700)
src/init-ceph.in

index 6545454b0db86a4d74c4116650f80d8c769ed353..7eb2f43ff226be0049c62caee69c40a7583f44df 100644 (file)
@@ -170,6 +170,17 @@ for name in $what; do
 
     check_host || continue
 
+    get_conf pid_file "/var/run/ceph/$type.$id.pid" "pid file"
+    [ -n "$pid_file" ] && mkdir -p `dirname $pid_file`
+
+    # start, and already running?  (do this check early to avoid unnecessary work!)
+    if [ "$command" = "start" ]; then
+       if daemon_is_running $name c$type $pid_file; then
+           echo "Starting Ceph $name on $host...already running"
+           continue
+       fi
+    fi
+
     # binary?
     binary="$BINDIR/c$type"
     if [ "$command" = "start" ]; then
@@ -200,9 +211,6 @@ for name in $what; do
        first_dev=`echo $btrfs_devs | cut '-d ' -f 1`
     fi
 
-    get_conf pid_file "/var/run/ceph/$type.$id.pid" "pid file"
-    [ -n "$pid_file" ] && mkdir -p `dirname $pid_file`
-
     case "$command" in
        start)
             # build final command
@@ -228,19 +236,14 @@ for name in $what; do
                echo Mounting Btrfs on $host:$btrfs_path
                do_root_cmd "modprobe btrfs ; btrfsctl -a ; egrep -q '^[^ ]+ $btrfs_path' /proc/mounts || mount -t btrfs $btrfs_opt $first_dev $btrfs_path"
            fi
-           echo -n Starting Ceph $name on $host...
-           if daemon_is_running $name c$type $pid_file; then
-               echo already running
-           else
-               echo
-               get_conf pre_start_eval "" "pre start eval"
-               [ -n "$pre_start_eval" ] && $pre_start_eval
-               get_conf pre_start "" "pre start command"
-               get_conf post_start "" "post start command"
-               [ -n "$pre_start" ] && do_cmd "$pre_start"
-               do_cmd "$cmd" $runarg
-               [ -n "$post_start" ] && do_cmd "$post_start"
-           fi
+           echo Starting Ceph $name on $host...
+           get_conf pre_start_eval "" "pre start eval"
+           [ -n "$pre_start_eval" ] && $pre_start_eval
+           get_conf pre_start "" "pre start command"
+           get_conf post_start "" "post start command"
+           [ -n "$pre_start" ] && do_cmd "$pre_start"
+           do_cmd "$cmd" $runarg
+           [ -n "$post_start" ] && do_cmd "$post_start"
            ;;
        
        stop)