#!/bin/bash

workDir=`dirname $0`
workDir=`cd ${workDir};pwd`
DBAPI_HOME=`cd "$workDir/.."; pwd`

source $DBAPI_HOME/conf/install_config.conf

apiServerHost=(${apiServers//,/ })
for apiServer in ${apiServerHost[@]}
do
  echo "$apiServer api server is starting"
	ssh -o StrictHostKeyChecking=no -p $sshPort $apiServer  "cd $DBAPI_HOME/; bash bin/dbapi-daemon.sh start apiServer;"
done

echo "$manager manager is starting"
ssh -o StrictHostKeyChecking=no -p $sshPort $manager  "cd $DBAPI_HOME/; bash bin/dbapi-daemon.sh start manager;"

echo "$gateway gateway is starting"
ssh -o StrictHostKeyChecking=no -p $sshPort $gateway  "cd $DBAPI_HOME/; bash bin/dbapi-daemon.sh start gateway;"

# query server status
echo "query server status"
cd $DBAPI_HOME/; bash bin/status-all.sh
