From 66a554d1e87b11a522dca9fc2155c4cd655b5113 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 17 Mar 2010 09:46:02 -0700 Subject: [PATCH] init-ceph: do already running check early to avoid extra work --- src/init-ceph.in | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/init-ceph.in b/src/init-ceph.in index 6545454b0db86..7eb2f43ff226b 100644 --- a/src/init-ceph.in +++ b/src/init-ceph.in @@ -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) -- 2.39.5