exec_tarbitrator.sh 1.5 KB
Newer Older
1
#!/bin/bash
H
Hui Li 已提交
2

G
Ganlin Zhao 已提交
3
# if [ $# != 2 || $# != 3 ]; then
H
Hui Li 已提交
4 5 6 7 8
  # echo "argument list need input : "
  # echo "  -s start/stop"
  # exit 1
# fi

G
Ganlin Zhao 已提交
9 10
UNAME_BIN=`which uname`
OS_TYPE=`$UNAME_BIN`
H
Hui Li 已提交
11
EXEC_OPTON=
G
Ganlin Zhao 已提交
12
while getopts "n:s:u:x:ct" arg
H
Hui Li 已提交
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
do
  case $arg in
    n)
      NODE_NAME=$OPTARG
      ;;
    s)
      EXEC_OPTON=$OPTARG
      ;;
    c)
      CLEAR_OPTION="clear"
      ;;
    t)
      SHELL_OPTION="true"
      ;;
    u)
      USERS=$OPTARG
      ;;
    x)
      SIGNAL=$OPTARG
      ;;
    ?)
      echo "unkown argument"
      ;;
  esac
done


SCRIPT_DIR=`dirname $0`
cd $SCRIPT_DIR/../
SCRIPT_DIR=`pwd`

44 45
IN_TDINTERNAL="community"
if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then
46 47 48 49 50
  cd ../../..
else
  cd ../../
fi

H
Hui Li 已提交
51
TAOS_DIR=`pwd`
S
Shuduo Sang 已提交
52
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
H
Hui Li 已提交
53

G
Ganlin Zhao 已提交
54 55 56 57 58 59
if [[ "$OS_TYPE" != "Darwin" ]]; then
  cut_opt="--field="
else
  cut_opt="-f "
fi

S
Shuduo Sang 已提交
60
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
G
Ganlin Zhao 已提交
61
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
S
Shuduo Sang 已提交
62
else
G
Ganlin Zhao 已提交
63
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2`
S
Shuduo Sang 已提交
64
fi
65

S
Shuduo Sang 已提交
66
BUILD_DIR=$TAOS_DIR/$BIN_DIR/build
67

H
Hui Li 已提交
68 69 70 71 72 73 74 75 76 77 78 79 80 81
SIM_DIR=$TAOS_DIR/sim
NODE_DIR=$SIM_DIR/arbitrator
EXE_DIR=$BUILD_DIR/bin
LOG_DIR=$NODE_DIR/log

echo "------------ $EXEC_OPTON tarbitrator"

if [ "$EXEC_OPTON" = "start" ]; then 
  echo "------------ log path: $LOG_DIR"
  nohup $EXE_DIR/tarbitrator -p 8000 -d 135 -g $LOG_DIR > /dev/null 2>&1 & 
else
  #relative path
  PID=`ps -ef|grep tarbitrator | grep -v grep | awk '{print $2}'`
  if [ -n "$PID" ]; then   
82 83
    kill -9 $PID
    pkill -9 tarbitrator
H
Hui Li 已提交
84 85 86
  fi 
fi