blob: 1c0d9a7dfebabe931d63ad339fde2204ce6978cb [file] [log] [blame]
yoshi28bac132014-01-22 11:00:17 -08001#!/bin/bash
2
Naoki Shiota4e463182014-03-21 15:13:24 -07003echo
4echo "========================================================================"
5echo "[WARNING] This script is deprecated. Use \"\$ ./onos.sh rc-coord\" instead."
6echo "========================================================================"
7echo
yoshi28bac132014-01-22 11:00:17 -08008
yoshi28bac132014-01-22 11:00:17 -08009# Set paths
10ONOS_HOME=`dirname $0`
11RAMCLOUD_DIR=${HOME}/ramcloud
Bob Lantz63bbe4c2014-02-06 19:29:55 -080012LOGDIR=${ONOS_LOGDIR:-${ONOS_HOME}/onos-logs}
yoshif2806402014-01-23 09:28:39 -080013RAMCLOUD_LOG=${LOGDIR}/ramcloud.coordinator.`hostname`.log
14coordinatorip=`grep coordinatorIp ${ONOS_HOME}/conf/ramcloud.conf | cut -d "=" -f 2,3`
15coordinatorport=`grep coordinatorPort ${ONOS_HOME}/conf/ramcloud.conf | cut -d "=" -f 2,3`
16RAMCLOUD_COORDINATOR=`echo $coordinatorip","$coordinatorport`
Yuta HIGUCHIa7ec0732014-03-10 16:01:06 -070017RAMCLOUD_BRANCH=${RAMCLOUD_BRANCH:-master}
yoshi28bac132014-01-22 11:00:17 -080018
19function lotate {
20 logfile=$1
21 nr_max=${2:-10}
22 if [ -f $logfile ]; then
23 for i in `seq $(expr $nr_max - 1) -1 1`; do
24 if [ -f ${logfile}.${i} ]; then
25 mv -f ${logfile}.${i} ${logfile}.`expr $i + 1`
26 fi
27 done
28 mv $logfile $logfile.1
29 fi
30}
31
32function start {
33 if [ ! -d ${LOGDIR} ]; then
34 mkdir -p ${LOGDIR}
35 fi
36 echo "rotate log: $log"
37 if [ -f $RAMCLOUD_LOG ]; then
38 lotate $RAMCLOUD_LOG
39 fi
40
41 # Run ramcloud
42 echo "Starting ramcloud coordinator"
Yuta HIGUCHIa7ec0732014-03-10 16:01:06 -070043 $RAMCLOUD_DIR/obj.${RAMCLOUD_BRANCH}/coordinator -L $RAMCLOUD_COORDINATOR > $RAMCLOUD_LOG 2>&1 &
yoshi28bac132014-01-22 11:00:17 -080044}
45
46function stop {
47 # Kill the existing processes
48 capid=`pgrep coordinator | awk '{print $1}'`
49 pids="$capid"
50 for p in ${pids}; do
51 if [ x$p != "x" ]; then
52 kill -KILL $p
53 echo "Killed existing prosess (pid: $p)"
54 fi
55 done
56}
57
58function deldb {
59# # Delete the berkeley db database
60 if [ -d "/tmp/ramcloud.conf" ]; then
61 echo "deleting berkeley db dir"
62 sudo rm -rf /tmp/ramcloud.conf
63 fi
64}
65
66case "$1" in
67 start)
68 deldb
69 cp $ONOS_HOME/conf/ramcloud.conf /tmp
70 stop
71 start
72 ;;
73 stop)
74 stop
75 ;;
76# deldb)
77# deldb
78# ;;
79 status)
Yuta HIGUCHIa7ec0732014-03-10 16:01:06 -070080 n=`pgrep -f obj.${RAMCLOUD_BRANCH}/coordinator | wc -l`
yoshi28bac132014-01-22 11:00:17 -080081 echo "$n ramcloud coordinator is running"
82 ;;
83 *)
84 echo "Usage: $0 {start|stop|restart|status}"
85 exit 1
86esac