blob: 161dc629a46da72a97ce6a3ed79e705e5793af8e [file] [log] [blame]
onlab-qa25193a62013-12-04 13:27:38 -08001#!/bin/bash
2
3# Set paths
4ONOS_HOME=`dirname $0`
5RAMCLOUD_DIR=${HOME}/ramcloud
6LOGDIR=${ONOS_HOME}/ONOS/onos-logs
7RAMCLOUD_LOG=${LOGDIR}/ramcloud.`hostname`.log
8RAMCLOUD_COORDINATOR="fast+udp:host=10.128.4.104,port=12246"
9RAMCLOUD_SERVER="fast+udp:host=10.128.100.35,port=12242"
10
11function lotate {
12 logfile=$1
13 nr_max=${2:-10}
14 if [ -f $logfile ]; then
15 for i in `seq $(expr $nr_max - 1) -1 1`; do
16 if [ -f ${logfile}.${i} ]; then
17 mv -f ${logfile}.${i} ${logfile}.`expr $i + 1`
18 fi
19 done
20 mv $logfile $logfile.1
21 fi
22}
23
24function start {
25 if [ ! -d ${LOGDIR} ]; then
26 mkdir -p ${LOGDIR}
27 fi
28 echo "rotate log: $log"
29 if [ -f $RAMCLOUD_LOG ]; then
30 lotate $RAMCLOUD_LOG
31 fi
32
33 # Run ramcloud
34 echo "Starting ramcloud"
35 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${HOME}/ramcloud/bindings/java/edu/stanford/ramcloud:${HOME}/ramcloud/obj.blueprint-java
36 $RAMCLOUD_DIR/obj/server -M -r 0 -L $RAMCLOUD_SERVER -C $RAMCLOUD_COORDINATOR > $RAMCLOUD_LOG 2>&1 &
37}
38
39function stop {
40 # Kill the existing processes
41 capid=`ps -edalf |grep ramcloud |grep obj/server | awk '{print $4}'`
42 pids="$capid"
43 for p in ${pids}; do
44 if [ x$p != "x" ]; then
45 kill -KILL $p
46 echo "Killed existing prosess (pid: $p)"
47 fi
48 done
49}
50
51function deldb {
52# # Delete the berkeley db database
53 if [ -d "/tmp/ramcloud.conf" ]; then
54 echo "deleting berkeley db dir"
55 sudo rm -rf /tmp/ramcloud.conf
56 fi
57}
58
59case "$1" in
60 start)
61 deldb
62 cp $ONOS_HOME/conf/ramcloud.conf /tmp
63 stop
64 start
65 ;;
66 stop)
67 stop
68 ;;
69# deldb)
70# deldb
71# ;;
72 status)
73 n=`ps -edalf |grep ramcloud |grep obj/server | wc -l`
74 echo "$n ramcloud server running"
75 ;;
76 *)
77 echo "Usage: $0 {start|stop|restart|status}"
78 exit 1
79esac