Unverified Commit 52daf2c1 authored by aiwenmo's avatar aiwenmo Committed by GitHub

[Improvement-456][dlink-doc] Fix start and stop conflicts when deploy more...

[Improvement-456][dlink-doc] Fix start and stop conflicts when deploy more instances in same machine

[Improvement-456][dlink-doc] Fix start and stop conflicts when deploy more instances in same machine
parents 1fe5bb0c 1436b525
...@@ -6,117 +6,117 @@ JAR_NAME="./dlink-admin-*.jar" ...@@ -6,117 +6,117 @@ JAR_NAME="./dlink-admin-*.jar"
# 如果需要将FLINK依赖直接加入启动脚本,在SETTING中增加$FLINK_HOME/lib # 如果需要将FLINK依赖直接加入启动脚本,在SETTING中增加$FLINK_HOME/lib
SETTING="-Dloader.path=./lib,./plugins -Ddruid.mysql.usePingMethod=false" SETTING="-Dloader.path=./lib,./plugins -Ddruid.mysql.usePingMethod=false"
if [ ! -d ${HADOOP_HOME} ];then if [ ! -d ${HADOOP_HOME} ]; then
echo 'WARNING!!!...not find HADOOP_HOME for CLASSPATH.' echo 'WARNING!!!...not find HADOOP_HOME for CLASSPATH.'
else else
export HADOOP_HOME="${HADOOP_HOME}" export HADOOP_HOME="${HADOOP_HOME}"
fi
PIDFILE="dink.pid"
#检查PID path 是否存在
PIDPATH="$(cd "$(dirname "$0")";pwd)/run"
if [ -d ${PIDPATH} ];then
echo "${PIDPATH} is already exist" >> /dev/null
else
#echo "create ${PIDPATH}"
mkdir -p ${PIDPATH}
fi
#检查PID File 是否存在
if [ -f "${PIDPATH}/${PIDFILE}" ];then
echo "${PIDPATH}/${PIDFILE} is already exist" >> /dev/null
else
touch ${PIDPATH}/${PIDFILE}
fi fi
# 首次启动时候自动创建plugins文件夹和引用flink\lib包! # 首次启动时候自动创建plugins文件夹和引用flink\lib包!
if [ ! -d "./plugins" ];then if [ ! -d "./plugins" ]; then
echo 'mkdir plugins now' echo 'mkdir plugins now'
mkdir plugins mkdir plugins
cd plugins cd plugins
if [ ! -d ${FLINK_HOME} ];then if [ ! -d ${FLINK_HOME} ]; then
echo 'WARNING!!!...没有找到FLINK_HOME环境变量,无法引用Flink/lib到plugins,请手动引用或复制Flink jar到plugins文件夹' echo 'WARNING!!!...没有找到FLINK_HOME环境变量,无法引用Flink/lib到plugins,请手动引用或复制Flink jar到plugins文件夹'
echo 'WARNING!!!...not find FLINK_HOME environment variable to reference Flink/lib to plugins, please reference or copy Flink jar to the plugins folder manually!!' echo 'WARNING!!!...not find FLINK_HOME environment variable to reference Flink/lib to plugins, please reference or copy Flink jar to the plugins folder manually!!'
else else
ln -s ${FLINK_HOME}/lib ln -s ${FLINK_HOME}/lib
cd .. cd ..
fi fi
fi fi
# 如果输入格式不对,给出提示! # 如果输入格式不对,给出提示!
tips() { tips() {
echo "" echo ""
echo "WARNING!!!......Tips, please use command: sh auto.sh [start|stop|restart|status]. For example: sh auto.sh start " echo "WARNING!!!......Tips, please use command: sh auto.sh [start|stop|restart|status]. For example: sh auto.sh start "
echo "" echo ""
exit 1 exit 1
} }
# 启动方法 # 启动方法
start() { start() {
# 重新获取一下pid,因为其它操作如stop会导致pid的状态更新
pid=`ps -ef | grep $JAR_NAME | grep -v grep | awk '{print $2}'` pid=$(cat ${PIDPATH}/${PIDFILE})
# -z 表示如果$pid为空时执行 if [ -z $pid ]; then
if [ -z $pid ]; then nohup java $SETTING -jar -Xms512M -Xmx2048M -XX:PermSize=512M -XX:MaxPermSize=1024M $JAR_NAME >dlink.log 2>&1 &
nohup java $SETTING -jar -Xms512M -Xmx2048M -XX:PermSize=512M -XX:MaxPermSize=1024M $JAR_NAME > dlink.log 2>&1 & echo $! >${PIDPATH}/${PIDFILE}
pid=`ps -ef | grep $JAR_NAME | grep -v grep | awk '{print $2}'` echo "........................................Start Dlink Successfully........................................"
echo ""
echo "Service ${JAR_NAME} is starting!pid=${pid}" else
echo "........................Start successfully!........................." echo "Dlink pid $pid is in ${PIDPATH}/${PIDFILE}, Please stop first !!!"
else fi
echo ""
echo "Service ${JAR_NAME} is already running,it's pid = ${pid}. If necessary, please use command: sh auto.sh restart."
echo ""
fi
} }
# 停止方法 # 停止方法
stop() { stop() {
# 重新获取一下pid,因为其它操作如start会导致pid的状态更新 pid=$(cat ${PIDPATH}/${PIDFILE})
pid=`ps -ef | grep $JAR_NAME | grep -v grep | awk '{print $2}'` if [ -z $pid ]; then
# -z 表示如果$pid为空时执行。 注意:每个命令和变量之间一定要前后加空格,否则会提示command找不到 echo "Dlink pid is not exist in ${PIDPATH}/${PIDFILE}"
if [ -z $pid ]; then else
echo "" kill -9 $pid
echo "Service ${JAR_NAME} is not running! It's not necessary to stop it!" sleep 1
echo "" echo "........................................Stop Dlink Successfully....................................."
else echo " " >${PIDPATH}/${PIDFILE}
kill -9 $pid fi
echo ""
echo "Service stop successfully!pid:${pid} which has been killed forcibly!"
echo ""
fi
} }
# 输出运行状态方法 # 输出运行状态方法
status() { status() {
# 重新获取一下pid,因为其它操作如stop、restart、start等会导致pid的状态更新 # 重新获取一下pid,因为其它操作如stop、restart、start等会导致pid的状态更新
pid=`ps -ef | grep $JAR_NAME | grep -v grep | awk '{print $2}'` pid=$(cat ${PIDPATH}/${PIDFILE})
# -z 表示如果$pid为空时执行。注意:每个命令和变量之间一定要前后加空格,否则会提示command找不到 if [ -z $pid ]; then
if [ -z $pid ];then echo ""
echo "" echo "Service ${JAR_NAME} is not running!"
echo "Service ${JAR_NAME} is not running!" echo ""
echo "" else
else echo ""
echo "" echo "Service ${JAR_NAME} is running. It's pid=${pid}"
echo "Service ${JAR_NAME} is running. It's pid=${pid}" echo ""
echo "" fi
fi
} }
# 重启方法 # 重启方法
restart() { restart() {
echo "" echo ""
echo ".............................Restarting.............................." stop
echo "....................................................................." start
# 重新获取一下pid,因为其它操作如start会导致pid的状态更新 echo "........................................Restart Successfully........................................"
pid=`ps -ef | grep $JAR_NAME | grep -v grep | awk '{print $2}'`
# -z 表示如果$pid为空时执行。 注意:每个命令和变量之间一定要前后加空格,否则会提示command找不到
if [ ! -z $pid ]; then
kill -9 $pid
fi
start
echo "....................Restart successfully!..........................."
} }
# 根据输入参数执行对应方法,不输入则执行tips提示方法 # 根据输入参数执行对应方法,不输入则执行tips提示方法
case "$1" in case "$1" in
"start") "start")
start start
;; ;;
"stop") "stop")
stop stop
;; ;;
"status") "status")
status status
;; ;;
"restart") "restart")
restart restart
;; ;;
*) *)
tips tips
;; ;;
esac esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment