]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
initscript: lots of changes
authorSage Weil <sage@newdream.net>
Wed, 11 Mar 2009 22:23:46 +0000 (15:23 -0700)
committerSage Weil <sage@newdream.net>
Wed, 11 Mar 2009 22:27:58 +0000 (15:27 -0700)
src/ceph_common.sh
src/init-ceph
src/mkcephfs
src/vstart.sh
src/workingdir.conf [deleted file]

index ea25032f4369250bf06db763d3a2d0d662689eb3..db398bea0e220346e0567a22bab1fb5dd16162e0 100644 (file)
@@ -101,12 +101,7 @@ get_conf() {
        key=$3
        shift; shift; shift
 
-       tmp=""
-       while [ $# -ge 1 ]; do
-               tmp=$tmp" -s $1"
-               shift
-       done
-       eval "$var=\"`$CCONF -c $conf $tmp \"$key\" \"$def\"`\""
+       eval "$var=\"`$CCONF -c $conf -i $id -t $type $tmp \"$key\" \"$def\"`\""
 }
 
 get_conf_bool() {
index 505c58b571fff32aae0c9857281d9c0aad311593..430d8bf0338288d27143aa57732c3525a662fd5e 100755 (executable)
@@ -25,7 +25,7 @@ fi
 
 usage_exit() {
     echo "usage: $0 [options] {start|stop|restart} [mon|osd|mds]..."
-    printf "\t-C cluster.conf\n"
+    printf "\t-c cluster.conf\n"
     printf "\t--valgrind\trun via valgrind\n"
     exit
 }
@@ -99,7 +99,7 @@ case $1 in
     --nobtrfs)
            dobtrfs=0
            ;;
-    --cluster-conf | -C)
+    --conf | -c)
            [ "$2" == "" ] && usage_exit
            options="$options $1"
            shift
@@ -135,86 +135,71 @@ for name in $what; do
     type=`echo $name | cut -c 1-3`   # e.g. 'mon', if $item is 'mon1'
     id=`echo $name | cut -c 4- | sed 's/\\.//'`
     num=$id
-    sections="$name $type global"
 
     check_host || continue
 
-    get_conf pid_file "/var/run/ceph/$name.pid" "pid file" $sections
-    get_conf runtimeconf "$runtime_conf" "conf" $sections
-
-    # extract name-specific options from $conf
-    if [[ $name =~ "mon" ]]; then
-       get_conf mon_data "" "mon data" $sections
-       module_opt="$mon_data"
-       module_bin="$BINDIR/cmon"
-    fi
-
-    if [[ $name =~ "mds" ]]; then
-       get_conf rank "" "rank" $sections
-       get_conf shadow "" "shadow" $sections
-       module_opt="$mon_addr_arg"
-       module_bin="$BINDIR/cmds $id"
-       [[ $rank != "" ]] && $module_bin="$module_bin --rank $mds"
-       [[ $shadow != "" ]] && $module_bin="$module_bin --shadow $shadow"
+    cmd="$BINDIR/c$type -i $id"
+
+    # conf file
+    if [[ $host == $hostname ]]; then
+       cmd="$cmd -c $conf"
+    else
+       if [[ ! $pushed_to =~ " $host " ]]; then
+           scp $conf $host:/tmp/ceph.conf.$$
+           pushed_to="$pushed_to $host "
+       fi
+       cmd="$cmd -c /tmp/ceph.conf.$$"
     fi
 
     if [[ $name =~ "osd" ]]; then
-       get_conf osd_data "" "osd data" $sections
-       get_conf osd_journal "" "osd journal" $sections
-       [ "$osd_journal" != "" ] && osd_journal_cmd="-j $osd_journal" || osd_journal_cmd=""
-       module_opt="$mon_addr_arg $osd_data $osd_journal_cmd"
-       module_bin="$BINDIR/cosd"
-
-       get_conf btrfs_path "$osd_data" "btrfs path" $sections  # mount point defaults so osd data
-       get_conf btrfs_devs "" "btrfs devs" $sections
+       get_conf osd_data "" "osd data"
+       get_conf btrfs_path "$osd_data" "btrfs path"  # mount point defaults so osd data
+       get_conf btrfs_devs "" "btrfs devs"
        first_dev=`echo $btrfs_devs | cut '-d ' -f 1`
     fi
 
-    module_opt="-p $pid_file -c $runtimeconf $module_opt"
-
     case "$command" in
        start)
             # build final command
            wrap=""
-           runflags=""
            runmode=""
            
-           get_conf_bool crun "$docrun" "restart on core dump" $sections
+           get_conf_bool crun "$docrun" "restart on core dump"
            [[ $crun -eq 1 ]] && wrap="$BINDIR/crun"
            
-           get_conf_bool valgrind "$dovalgrind" "valgrind" $sections
+           get_conf_bool valgrind "$dovalgrind" "valgrind"
            [[ $valgrind -eq 1 ]] && wrap="$wrap valgrind"
            
-           [[ $wrap != "" ]] && runflags="-f" && runmode="&"
+           [[ $wrap != "" ]] && runmode="-f &"
            
-           cmd="$wrap $module_bin $runflags $module_opt $runmode"
+           cmd="$wrap $cmd $runmode"
            
            echo Starting ceph $name on $host...
            if [ $dobtrfs -eq 1 ]; then
-               get_conf pre_mount "true" "pre mount command" $sections
+               get_conf pre_mount "true" "pre mount command"
                [[ $pre_mount != "" ]] && do_cmd $pre_mount
                do_cmd "mount -t btrfs $first_dev $btrfs_path"
            fi
-           get_conf pre_start_eval "" "pre start eval" $sections
+           get_conf pre_start_eval "" "pre start eval"
            [[ $pre_start_eval != "" ]] && $pre_start_eval
-           get_conf pre_start "" "pre start command" $sections
-           get_conf post_start "" "post start command" $sections
+           get_conf pre_start "" "pre start command"
+           get_conf post_start "" "post start command"
             [[ $pre_start != "" ]] && do_cmd $pre_start
            do_cmd "$cmd"
             [[ $post_start != "" ]] && do_cmd $post_start
            ;;
        
        stop)
-           get_conf pre_stop "" "pre stop command" $sections
-           get_conf post_stop "" "post stop command" $sections
+           get_conf pre_stop "" "pre stop command"
+           get_conf post_stop "" "post stop command"
            [[ $pre_stop != "" ]] && do_cmd $pre_stop
            stop_daemon $name c$type $pid_file
            [[ $post_stop != "" ]] && do_cmd $post_stop
            ;;
 
        forcestop)
-           get_conf pre_forcestop "" "pre forcestop command" $sections
-           get_conf post_forcestop "" "post forcestop command" $sections
+           get_conf pre_forcestop "" "pre forcestop command"
+           get_conf post_forcestop "" "post forcestop command"
            [[ $pre_forcestop != "" ]] && do_cmd $pre_forcestop
            stop_daemon $name c$type $pid_file -9
            [[ $post_forcestop != "" ]] && do_cmd $post_forcestop
@@ -235,14 +220,14 @@ for name in $what; do
            ;;
 
        cleanlogs)
-           get_conf log_dir "/var/log/ceph" "log dir" $sections
-           get_conf log_sym_dir "/var/log/ceph" "log sym dir" $sections
+           get_conf log_dir "/var/log/ceph" "log dir"
+           get_conf log_sym_dir "/var/log/ceph" "log sym dir"
            do_cmd "for f in $log_sym_dir/$name*; do rm -f \`readlink \$f\` ; rm -f \$f ; done"
            ;;
 
        cleanalllogs)
-           get_conf log_dir "/var/log/ceph" "log dir" $sections
-           get_conf log_sym_dir "/var/log/ceph" "log sym dir" $sections
+           get_conf log_dir "/var/log/ceph" "log dir"
+           get_conf log_sym_dir "/var/log/ceph" "log sym dir"
            do_cmd "rm -f $log_dir/* $log_sym_dir/*"
            ;;
 
index 95bfa34291d96ff7ce799cc98e0b9b2e43c30df5..aad990b8f0424fccb06a0e902025732daaac1c02 100755 (executable)
@@ -114,27 +114,26 @@ for name in $what; do
     type=`echo $name | cut -c 1-3`   # e.g. 'mon', if $name is 'mon1'
     id=`echo $name | cut -c 4- | sed 's/\\.//'`
     num=$id
-    sections="$name $type global"
 
     check_host || continue
 
-    get_conf runtimeconf "$runtime_conf" "conf" $sections
+    get_conf runtimeconf "$runtime_conf" "conf"
 
-    if [[ $ssh = 1 ]] && [[ ! $pushed_to =~ " $host " ]]; then
+    if [[ $ssh != "" ]] && [[ ! $pushed_to =~ " $host " ]]; then
        scp $osdmap $host:$osdmap
        scp $monmap $host:$monmap
        pushed_to="$pushed_to $host "
     fi
 
     if [[ $type = "mon" ]]; then
-       get_conf mon_data "" "mon data" $sections
+       get_conf mon_data "" "mon data"
        do_cmd "$BINDIR/mkmonfs $clobber $mon_data --mon $num --monmap $monmap --osdmap $osdmap"
     fi
 
     if [[ $type = "osd" ]]; then
-       get_conf osd_path "" "osd data" $sections
-       get_conf btrfs_path "$osd_path" "btrfs path" $sections  # mount point defaults so osd path
-       get_conf btrfs_devs "" "btrfs devs" $sections
+       get_conf osd_path "" "osd data"
+       get_conf btrfs_path "$osd_path" "btrfs path"  # mount point defaults so osd path
+       get_conf btrfs_devs "" "btrfs devs"
        first_dev=`echo $btrfs_devs | cut '-d ' -f 1`
        
        if [ $mkbtrfs -eq 1 ]; then
index 6c3e64b28ce807f4ed5461d769cf6f4583a39dbe..3d7f6c3702d02d87b8db65a79033876e546f3830 100755 (executable)
@@ -14,8 +14,7 @@ let localhost=0
 valgrind=""
 MON_ADDR=""
 
-conf="workingdir.conf"
-clusterconf="cluster.conf"
+conf="cluster.conf"
 
 usage="usage: $0 [option]... [mon] [mds] [osd]\n"
 usage=$usage"options:\n"
@@ -131,7 +130,16 @@ if [ $start_mon -eq 1 ]; then
        fi
 
        if [ $new -eq 1 ]; then
-               echo "; generated by vstart.sh on `date`" > $clusterconf
+               cat <<EOF > $conf
+; generated by vstart.sh on `date`
+[global]
+       log dir = out
+       log sym dir = out
+       logger dir = log
+       chdir = ""
+       pid file = out/\$name.pid
+
+EOF
                if [ `echo $IP | grep '^127\\.'` ]
                then
                        echo
@@ -147,8 +155,11 @@ if [ $start_mon -eq 1 ]; then
                for f in `seq 0 $((CEPH_NUM_MON-1))`
                do
                        str=$str" --add $IP:$(($CEPH_PORT+$f))"
-                       echo "[mon$f]" >> $clusterconf
-                       echo " mon addr = $IP:$(($CEPH_PORT+$f))" >> $clusterconf
+                       cat <<EOF >> $conf
+[mon$f]
+        mon data = "dev/mon$f"
+        mon addr = $IP:$(($CEPH_PORT+$f))
+EOF
                done
                str=$str" --print .ceph_monmap"
                echo $str
@@ -156,15 +167,15 @@ if [ $start_mon -eq 1 ]; then
 
                for f in `seq 0 $((CEPH_NUM_MON-1))`
                do
-                       $CEPH_BIN/mkmonfs --clobber mondata/mon$f --mon $f --monmap .ceph_monmap --osdmap .ceph_osdmap
+                       $CEPH_BIN/mkmonfs --clobber dev/mon$f --mon $f --monmap .ceph_monmap --osdmap .ceph_osdmap
                done
        fi
 
        # start monitors
        if [ $start_mon -ne 0 ]; then
                for f in `seq 0 $((CEPH_NUM_MON-1))`; do
-                   echo $valgrind $CEPH_BIN/cmon mondata/mon$f $ARGS $CMON_ARGS 
-                   $valgrind $CEPH_BIN/cmon -p out/mon$f.pid mondata/mon$f $ARGS $CMON_ARGS 
+                   echo $valgrind $CEPH_BIN/cmon -i $f $ARGS $CMON_ARGS 
+                   $valgrind $CEPH_BIN/cmon -$f $ARGS $CMON_ARGS 
                done
                sleep 1
        fi
@@ -175,13 +186,15 @@ if [ $start_osd -eq 1 ]; then
        for osd in `seq 0 $((CEPH_NUM_OSD-1))`
        do
                if [ $new -eq 1 ]; then
+                   cat <<EOF >> $conf
+[osd$osd]
+        osd data = dev/osd$osd
+EOF
                        echo mkfs osd$osd
-                       $SUDO $CEPH_BIN/cosd $ARGS --mkfs_for_osd $osd dev/osd$osd # --debug_journal 20 --debug_osd 20 --debug_filestore 20 --debug_ebofs 20
+                       $SUDO $CEPH_BIN/cosd -i $osd $ARGS --mkfs # --debug_journal 20 --debug_osd 20 --debug_filestore 20 --debug_ebofs 20
                fi
                echo start osd$osd
-               echo $valgrind $SUDO $CEPH_BIN/cosd -m $IP:$CEPH_PORT dev/osd$osd $ARGS $COSD_ARGS
-               $valgrind $SUDO $CEPH_BIN/cosd -p out/osd$f.pid -m $IP:$CEPH_PORT dev/osd$osd $ARGS $COSD_ARGS
-# echo valgrind --leak-check=full --show-reachable=yes $CEPH_BIN/cosd dev/osd$osd --debug_ms 1 --debug_osd 20 --debug_filestore 10 --debug_ebofs 20 #1>out/o$osd #& #--debug_osd 40
+               $valgrind $SUDO $CEPH_BIN/cosd -p out/osd$f.pid -m $IP:$CEPH_PORT -i $osd $ARGS $COSD_ARGS
        done
 fi
 
@@ -189,8 +202,7 @@ fi
 if [ $start_mds -eq 1 ]; then
        for mds in `seq 0 $((CEPH_NUM_MDS-1))`
        do
-               echo $valgrind $CEPH_BIN/cmds $ARGS $CMDS_ARGS
-               $valgrind $CEPH_BIN/cmds $ARGS $CMDS_ARGS
+               $valgrind $CEPH_BIN/cmds -i $mds $ARGS $CMDS_ARGS
 
 #valgrind --tool=massif $CEPH_BIN/cmds $ARGS --mds_log_max_segments 2 --mds_thrash_fragments 0 --mds_thrash_exports 0 > m  #--debug_ms 20
 #$CEPH_BIN/cmds -d $ARGS --mds_thrash_fragments 0 --mds_thrash_exports 0 #--debug_ms 20
diff --git a/src/workingdir.conf b/src/workingdir.conf
deleted file mode 100644 (file)
index 58395e7..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# specify log, stat paths relative to the current directory.  useful
-# when running out of the directory you've compiled in.
-#
-[global]
-       log dir = out
-       log sym dir = out
-       logger dir = log
-       chdir = ""
-