blob: 395a234f97d41c7513df0f613f778b7667141f47 [file] [log] [blame]
onlab-qa25193a62013-12-04 13:27:38 -08001#!/bin/bash
2
Naoki Shiota4e463182014-03-21 15:13:24 -07003echo
4echo "========================================================================="
5echo "[WARNING] This script is deprecated. Use \"\$ ./onos.sh rc-server\" instead."
6echo "========================================================================="
7echo
8
yoshi391d68d2014-01-21 11:56:59 -08009ulimit -c unlimited
yoshi391d68d2014-01-21 11:56:59 -080010
onlab-qa25193a62013-12-04 13:27:38 -080011# Set paths
12ONOS_HOME=`dirname $0`
13RAMCLOUD_DIR=${HOME}/ramcloud
Bob Lantz63bbe4c2014-02-06 19:29:55 -080014LOGDIR=${ONOS_LOGDIR:-${ONOS_HOME}/onos-logs}
yoshif2806402014-01-23 09:28:39 -080015RAMCLOUD_LOG=${LOGDIR}/ramcloud.server.`hostname`.log
Jonathan Hartd7241452014-03-20 16:45:35 -070016RAMCLOUD_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`
21COORDINATOR_IP=`grep coordinatorIp ${RAMCLOUD_CONF} | cut -d "=" -f 2,3`
22COORDINATOR_PORT=`grep coordinatorPort ${RAMCLOUD_CONF} | cut -d "=" -f 2,3`
23RAMCLOUD_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
29SERVER_IP=`grep serverIp ${RAMCLOUD_CONF} | cut -d "=" -f 2,3`
30SERVER_PORT=`grep serverPort ${RAMCLOUD_CONF} | cut -d "=" -f 2,3`
31RAMCLOUD_SERVER=`echo $SERVER_IP","$SERVER_PORT`
32
Yuta HIGUCHIa7ec0732014-03-10 16:01:06 -070033RAMCLOUD_BRANCH=${RAMCLOUD_BRANCH:-master}
onlab-qa25193a62013-12-04 13:27:38 -080034
35function 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
48function 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 HIGUCHI43ab5c62014-02-25 15:11:25 -080057 # Run ramcloud
onlab-qa25193a62013-12-04 13:27:38 -080058 echo "Starting ramcloud"
Yuta HIGUCHIa7ec0732014-03-10 16:01:06 -070059 $RAMCLOUD_DIR/obj.${RAMCLOUD_BRANCH}/server -M -L $RAMCLOUD_SERVER -C $RAMCLOUD_COORDINATOR --masterServiceThreads 1 --logCleanerThreads 1 --detectFailures 0 > $RAMCLOUD_LOG 2>&1 &
onlab-qa25193a62013-12-04 13:27:38 -080060}
61
62function stop {
63 # Kill the existing processes
Yuta HIGUCHIa7ec0732014-03-10 16:01:06 -070064 capid=`pgrep -f obj.${RAMCLOUD_BRANCH}/server | awk '{print $1}'`
onlab-qa25193a62013-12-04 13:27:38 -080065 pids="$capid"
66 for p in ${pids}; do
67 if [ x$p != "x" ]; then
68 kill -KILL $p
Jonathan Hartd7241452014-03-20 16:45:35 -070069 echo "Killed existing process (pid: $p)"
onlab-qa25193a62013-12-04 13:27:38 -080070 fi
71 done
72}
73
onlab-qa25193a62013-12-04 13:27:38 -080074case "$1" in
75 start)
Jonathan Hartd7241452014-03-20 16:45:35 -070076 #cp $ONOS_HOME/conf/ramcloud.conf /tmp
onlab-qa25193a62013-12-04 13:27:38 -080077 stop
78 start
79 ;;
80 stop)
81 stop
82 ;;
onlab-qa25193a62013-12-04 13:27:38 -080083 status)
Yuta HIGUCHIa7ec0732014-03-10 16:01:06 -070084 n=`pgrep -f obj.${RAMCLOUD_BRANCH}/server | wc -l`
onlab-qa25193a62013-12-04 13:27:38 -080085 echo "$n ramcloud server running"
86 ;;
87 *)
88 echo "Usage: $0 {start|stop|restart|status}"
89 exit 1
90esac