From 72d71177718fd0943231088dc260dcf2138b030f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 12 Feb 2010 14:20:02 -0800 Subject: [PATCH] init-ceph: print 'already started' instead of failing to start --- src/ceph_common.sh | 6 +++--- src/init-ceph.in | 31 +++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/ceph_common.sh b/src/ceph_common.sh index 359d25a6e14b6..32fc232fe4c86 100644 --- a/src/ceph_common.sh +++ b/src/ceph_common.sh @@ -65,13 +65,13 @@ do_cmd() { ulimit -c unlimited whoami=`whoami` if [ "$whoami" = "$user" ] || [ -z "$user" ]; then - bash -c "$1" || { echo "failed: '$1'" ; exit 1; } + bash -c "$1" || { [ -z "$3" ] && echo "failed: '$1'" && exit 1; } else - sudo su $user -c "$1" || { echo "failed: '$1'" ; exit 1; } + sudo su $user -c "$1" || { [ -z "$3" ] && echo "failed: '$1'" && exit 1; } fi else [ $verbose -eq 1 ] && echo "--- $ssh $2 \"cd $dir ; ulimit -c unlimited ; $1\"" - $ssh $2 "cd $dir ; ulimit -c unlimited ; $1" || { echo "failed: '$ssh $1'" ; exit 1; } + $ssh $2 "cd $dir ; ulimit -c unlimited ; $1" || { [ -z "$3" ] && echo "failed: '$ssh $1'" && exit 1; } fi } diff --git a/src/init-ceph.in b/src/init-ceph.in index 90caf2f9e1c0d..d3be627f99532 100644 --- a/src/init-ceph.in +++ b/src/init-ceph.in @@ -57,6 +57,16 @@ signal_daemon() { echo done } +daemon_is_running() { + name=$1 + daemon=$2 + pidfile=$3 + do_cmd "[ -e $pidfile ] || exit 1 # no pid, presumably not running + pid=\`cat $pidfile\` + [ -e /proc/\$pid ] && grep -q $daemon /proc/\$pid/cmdline && exit 0 # running + exit 1 # pid is something else" "" "okfail" +} + stop_daemon() { name=$1 daemon=$2 @@ -218,14 +228,19 @@ 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 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" + 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 ;; stop) -- 2.39.5