[Fix-12109]Fix the errors when starting 2 times with dolphinscheduler-daemon.sh (#12118)
This commit is contained in:
parent
4e2701b57e
commit
fd18e37da7
|
|
@ -28,8 +28,6 @@ startStop=$1
|
|||
shift
|
||||
command=$1
|
||||
shift
|
||||
CLASS=$1
|
||||
shift
|
||||
|
||||
echo "Begin $startStop $command......"
|
||||
|
||||
|
|
@ -81,8 +79,25 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
state=""
|
||||
function get_server_running_status() {
|
||||
state="STOP"
|
||||
if [ -f $pid ]; then
|
||||
TARGET_PID=`cat $pid`
|
||||
if [[ $(ps -p "$TARGET_PID" -o comm=) =~ "bash" ]]; then
|
||||
state="RUNNING"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
case $startStop in
|
||||
(start)
|
||||
# if server is already started, cancel this launch
|
||||
get_server_running_status
|
||||
if [[ $state == "RUNNING" ]]; then
|
||||
echo "$command running as process $TARGET_PID. Stop it first."
|
||||
exit 1
|
||||
fi
|
||||
echo starting $command, logging to $DOLPHINSCHEDULER_LOG_DIR
|
||||
overwrite_server_env "${command}"
|
||||
nohup /bin/bash "$DOLPHINSCHEDULER_HOME/$command/bin/start.sh" > $log 2>&1 &
|
||||
|
|
@ -110,13 +125,11 @@ case $startStop in
|
|||
;;
|
||||
|
||||
(status)
|
||||
# more details about the status can be added later
|
||||
serverCount=`ps -ef | grep "java" | grep "$DOLPHINSCHEDULER_HOME" | grep "$CLASS" | grep -v "grep" | wc -l`
|
||||
state="STOP"
|
||||
get_server_running_status
|
||||
if [[ $state == "STOP" ]]; then
|
||||
# font color - red
|
||||
state="[ \033[1;31m $state \033[0m ]"
|
||||
if [[ $serverCount -gt 0 ]];then
|
||||
state="RUNNING"
|
||||
else
|
||||
# font color - green
|
||||
state="[ \033[1;32m $state \033[0m ]"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -49,25 +49,25 @@ StateRunning="Running"
|
|||
mastersHost=(${masters//,/ })
|
||||
for master in ${mastersHost[@]}
|
||||
do
|
||||
masterState=`ssh -o StrictHostKeyChecking=no -p $sshPort $master "cd $installPath/; bash bin/dolphinscheduler-daemon.sh status master-server org.apache.dolphinscheduler.server.master.MasterServer;"`
|
||||
masterState=`ssh -o StrictHostKeyChecking=no -p $sshPort $master "cd $installPath/; bash bin/dolphinscheduler-daemon.sh status master-server;"`
|
||||
echo "$master $masterState"
|
||||
done
|
||||
|
||||
# 2.worker server check state
|
||||
for worker in ${workerNames[@]}
|
||||
do
|
||||
workerState=`ssh -o StrictHostKeyChecking=no -p $sshPort $worker "cd $installPath/; bash bin/dolphinscheduler-daemon.sh status worker-server org.apache.dolphinscheduler.server.worker.WorkerServer;"`
|
||||
workerState=`ssh -o StrictHostKeyChecking=no -p $sshPort $worker "cd $installPath/; bash bin/dolphinscheduler-daemon.sh status worker-server;"`
|
||||
echo "$worker $workerState"
|
||||
done
|
||||
|
||||
# 3.alter server check state
|
||||
alertState=`ssh -o StrictHostKeyChecking=no -p $sshPort $alertServer "cd $installPath/; bash bin/dolphinscheduler-daemon.sh status alert-server org.apache.dolphinscheduler.alert.AlertServer;"`
|
||||
alertState=`ssh -o StrictHostKeyChecking=no -p $sshPort $alertServer "cd $installPath/; bash bin/dolphinscheduler-daemon.sh status alert-server;"`
|
||||
echo "$alertServer $alertState"
|
||||
|
||||
# 4.api server check state
|
||||
apiServersHost=(${apiServers//,/ })
|
||||
for apiServer in ${apiServersHost[@]}
|
||||
do
|
||||
apiState=`ssh -o StrictHostKeyChecking=no -p $sshPort $apiServer "cd $installPath/; bash bin/dolphinscheduler-daemon.sh status api-server org.apache.dolphinscheduler.api.ApiApplicationServer;"`
|
||||
apiState=`ssh -o StrictHostKeyChecking=no -p $sshPort $apiServer "cd $installPath/; bash bin/dolphinscheduler-daemon.sh status api-server;"`
|
||||
echo "$apiServer $apiState"
|
||||
done
|
||||
|
|
|
|||
Loading…
Reference in New Issue