]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
init-ceph: Make sure daemon_is_running() checks the correct instance
authorJim Schutt <jaschut@sandia.gov>
Thu, 21 Oct 2010 16:32:09 +0000 (10:32 -0600)
committerSage Weil <sage@newdream.net>
Thu, 21 Oct 2010 18:18:08 +0000 (11:18 -0700)
When starting multiple instances of a daemon on a single host,
for unknown reasons /var/run/ceph/$type.$id.pid can hold a pid
for which /proc/$pid/cmdline identifies the right type of daemon,
but the wrong instance.  When this happens, all the configured
instances of a daemon are not running, but repeated invocations
of "init-ceph start" do not start the missing instances.

So, check for the correct daemon instance id as well as type when
testing if the daemon is up.

Signed-off-by: Jim Schutt <jaschut@sandia.gov>
Signed-off-by: Sage Weil <sage@newdream.net>
src/init-ceph.in

index 52891c073bb047f022c400428fedd6d6f66bfdf1..d42a80651bb71954931728729b39607abe65919e 100644 (file)
@@ -69,10 +69,11 @@ signal_daemon() {
 daemon_is_running() {
     name=$1
     daemon=$2
-    pidfile=$3
+    daemon_id=$3
+    pidfile=$4
     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
+       [ -e /proc/\$pid ] && grep -q $daemon /proc/\$pid/cmdline && grep -qwe -i.$daemon_id /proc/\$pid/cmdline && exit 0 # running
         exit 1  # pid is something else" "" "okfail"
 }
 
@@ -195,7 +196,7 @@ for name in $what; do
 
     # 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
+       if daemon_is_running $name c$type $id $pid_file; then
            echo "Starting Ceph $name on $host...already running"
            continue
        fi