onlab-qa | 25193a6 | 2013-12-04 13:27:38 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Naoki Shiota | 4e46318 | 2014-03-21 15:13:24 -0700 | [diff] [blame] | 3 | echo |
| 4 | echo "=========================================================================" |
| 5 | echo "[WARNING] This script is deprecated. Use \"\$ ./onos.sh rc-server\" instead." |
| 6 | echo "=========================================================================" |
| 7 | echo |
| 8 | |
yoshi | 391d68d | 2014-01-21 11:56:59 -0800 | [diff] [blame] | 9 | ulimit -c unlimited |
yoshi | 391d68d | 2014-01-21 11:56:59 -0800 | [diff] [blame] | 10 | |
onlab-qa | 25193a6 | 2013-12-04 13:27:38 -0800 | [diff] [blame] | 11 | # Set paths |
| 12 | ONOS_HOME=`dirname $0` |
| 13 | RAMCLOUD_DIR=${HOME}/ramcloud |
Bob Lantz | 63bbe4c | 2014-02-06 19:29:55 -0800 | [diff] [blame] | 14 | LOGDIR=${ONOS_LOGDIR:-${ONOS_HOME}/onos-logs} |
yoshi | f280640 | 2014-01-23 09:28:39 -0800 | [diff] [blame] | 15 | RAMCLOUD_LOG=${LOGDIR}/ramcloud.server.`hostname`.log |
Jonathan Hart | d724145 | 2014-03-20 16:45:35 -0700 | [diff] [blame] | 16 | RAMCLOUD_CONF=${RAMCLOUD_CONF:-${ONOS_HOME}/conf/ramcloud.conf} |
| 17 | |
| 18 | #coordinatorip=`grep coordinatorIp ${ONOS_HOME}/conf/ramcloud.conf | cut -d "=" -f 2,3` |
| 19 | #coordinatorport=`grep coordinatorPort ${ONOS_HOME}/conf/ramcloud.conf | cut -d "=" -f 2,3` |
| 20 | #RAMCLOUD_COORDINATOR=`echo $coordinatorip","$coordinatorport` |
| 21 | COORDINATOR_IP=`grep coordinatorIp ${RAMCLOUD_CONF} | cut -d "=" -f 2,3` |
| 22 | COORDINATOR_PORT=`grep coordinatorPort ${RAMCLOUD_CONF} | cut -d "=" -f 2,3` |
| 23 | RAMCLOUD_COORDINATOR=`echo $COORDINATOR_IP","$COORDINATOR_PORT` |
| 24 | |
| 25 | #serverip=`grep serverIp ${ONOS_HOME}/conf/ramcloud.conf | cut -d "=" -f 2,3` |
| 26 | #serverport=`grep serverPort ${ONOS_HOME}/conf/ramcloud.conf | cut -d "=" -f 2,3` |
| 27 | #RAMCLOUD_SERVER=`echo $serverip","$serverport` |
| 28 | |
| 29 | SERVER_IP=`grep serverIp ${RAMCLOUD_CONF} | cut -d "=" -f 2,3` |
| 30 | SERVER_PORT=`grep serverPort ${RAMCLOUD_CONF} | cut -d "=" -f 2,3` |
| 31 | RAMCLOUD_SERVER=`echo $SERVER_IP","$SERVER_PORT` |
| 32 | |
Yuta HIGUCHI | a7ec073 | 2014-03-10 16:01:06 -0700 | [diff] [blame] | 33 | RAMCLOUD_BRANCH=${RAMCLOUD_BRANCH:-master} |
onlab-qa | 25193a6 | 2013-12-04 13:27:38 -0800 | [diff] [blame] | 34 | |
| 35 | function lotate { |
| 36 | logfile=$1 |
| 37 | nr_max=${2:-10} |
| 38 | if [ -f $logfile ]; then |
| 39 | for i in `seq $(expr $nr_max - 1) -1 1`; do |
| 40 | if [ -f ${logfile}.${i} ]; then |
| 41 | mv -f ${logfile}.${i} ${logfile}.`expr $i + 1` |
| 42 | fi |
| 43 | done |
| 44 | mv $logfile $logfile.1 |
| 45 | fi |
| 46 | } |
| 47 | |
| 48 | function start { |
| 49 | if [ ! -d ${LOGDIR} ]; then |
| 50 | mkdir -p ${LOGDIR} |
| 51 | fi |
| 52 | echo "rotate log: $log" |
| 53 | if [ -f $RAMCLOUD_LOG ]; then |
| 54 | lotate $RAMCLOUD_LOG |
| 55 | fi |
| 56 | |
Yuta HIGUCHI | 43ab5c6 | 2014-02-25 15:11:25 -0800 | [diff] [blame] | 57 | # Run ramcloud |
onlab-qa | 25193a6 | 2013-12-04 13:27:38 -0800 | [diff] [blame] | 58 | echo "Starting ramcloud" |
Yuta HIGUCHI | a7ec073 | 2014-03-10 16:01:06 -0700 | [diff] [blame] | 59 | $RAMCLOUD_DIR/obj.${RAMCLOUD_BRANCH}/server -M -L $RAMCLOUD_SERVER -C $RAMCLOUD_COORDINATOR --masterServiceThreads 1 --logCleanerThreads 1 --detectFailures 0 > $RAMCLOUD_LOG 2>&1 & |
onlab-qa | 25193a6 | 2013-12-04 13:27:38 -0800 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | function stop { |
| 63 | # Kill the existing processes |
Yuta HIGUCHI | a7ec073 | 2014-03-10 16:01:06 -0700 | [diff] [blame] | 64 | capid=`pgrep -f obj.${RAMCLOUD_BRANCH}/server | awk '{print $1}'` |
onlab-qa | 25193a6 | 2013-12-04 13:27:38 -0800 | [diff] [blame] | 65 | pids="$capid" |
| 66 | for p in ${pids}; do |
| 67 | if [ x$p != "x" ]; then |
| 68 | kill -KILL $p |
Jonathan Hart | d724145 | 2014-03-20 16:45:35 -0700 | [diff] [blame] | 69 | echo "Killed existing process (pid: $p)" |
onlab-qa | 25193a6 | 2013-12-04 13:27:38 -0800 | [diff] [blame] | 70 | fi |
| 71 | done |
| 72 | } |
| 73 | |
onlab-qa | 25193a6 | 2013-12-04 13:27:38 -0800 | [diff] [blame] | 74 | case "$1" in |
| 75 | start) |
Jonathan Hart | d724145 | 2014-03-20 16:45:35 -0700 | [diff] [blame] | 76 | #cp $ONOS_HOME/conf/ramcloud.conf /tmp |
onlab-qa | 25193a6 | 2013-12-04 13:27:38 -0800 | [diff] [blame] | 77 | stop |
| 78 | start |
| 79 | ;; |
| 80 | stop) |
| 81 | stop |
| 82 | ;; |
onlab-qa | 25193a6 | 2013-12-04 13:27:38 -0800 | [diff] [blame] | 83 | status) |
Yuta HIGUCHI | a7ec073 | 2014-03-10 16:01:06 -0700 | [diff] [blame] | 84 | n=`pgrep -f obj.${RAMCLOUD_BRANCH}/server | wc -l` |
onlab-qa | 25193a6 | 2013-12-04 13:27:38 -0800 | [diff] [blame] | 85 | echo "$n ramcloud server running" |
| 86 | ;; |
| 87 | *) |
| 88 | echo "Usage: $0 {start|stop|restart|status}" |
| 89 | exit 1 |
| 90 | esac |