未验证 提交 2da1935f 编写于 作者: F Fankux 提交者: GitHub

Merge pull request #15 from fankux/master

remaster run script
#!/usr/bin/env bash #!/usr/bin/env bash
BIN='logproxy' cd $(dirname $0)
DEPLOY_PATH=$(pwd)
echo "DEPLOY_PATH : "${DEPLOY_PATH}
BIN='logproxy'
GPID=0 GPID=0
function is_running() function is_running() {
{ for pid in $(ps ux | grep ${BIN} | grep -v 'bash ' | grep -v grep | awk '{print $2}'); do
DEPLOY_PATH=$1
PROC_BIN_NAME=$2
for pid in `ps ux | grep ${PROC_BIN_NAME} | awk '{print $2}'`; do
_path=$(readlink -f /proc/${pid}/cwd) _path=$(readlink -f /proc/${pid}/cwd)
if [[ ${?} -eq 0 ]] && [[ ${_path} = ${DEPLOY_PATH} ]]; then if [[ ${?} -eq 0 ]] && [[ ${_path} == ${DEPLOY_PATH} ]]; then
GPID=${pid} GPID=${pid}
echo "is_running : (${GPID})${DEPLOY_PATH} ${PROC_BIN_NAME} is running!" echo "is_running : (${GPID})${DEPLOY_PATH} ${BIN} is running!"
return 1 return 1
fi fi
done done
return 0 return 0
} }
function kill_proc_9() function kill_proc_9() {
{ force=$1
DEPLOY_PATH=$1
PROC_BIN_NAME=$2
force=$3
[[ ! -d ${DEPLOY_PATH} ]] && { if [[ ! -d ${DEPLOY_PATH} ]]; then
echo "@@@@@@@@@@@@@@@ kill_proc : ${DEPLOY_PATH} invalid!" echo "kill_proc : ${DEPLOY_PATH} invalid!"
return 0 return 0
} fi
retry=0 retry=0
is_running ${DEPLOY_PATH} ${PROC_BIN_NAME} is_running
status=$? status=$?
while [[ ${status} -eq 1 ]]; do while [[ ${status} -eq 1 ]]; do
if [ ! -z ${force} ]; then if [ ! -z ${force} ]; then
...@@ -41,19 +38,18 @@ function kill_proc_9() ...@@ -41,19 +38,18 @@ function kill_proc_9()
echo "kill_proc : (${GPID})${DEPLOY_PATH} succ!" echo "kill_proc : (${GPID})${DEPLOY_PATH} succ!"
fi fi
sleep 1 sleep 1
retry=`expr ${retry} + 1` retry=$(expr ${retry} + 1)
if [ ${retry} -gt 15 ]; then if [ ${retry} -gt 15 ]; then
force=1 force=1
fi fi
is_running ${DEPLOY_PATH} ${PROC_BIN_NAME} is_running
status=$? status=$?
done done
return 0 return 0
} }
start() start() {
{
stop stop
if [ ! -d "./run" ]; then if [ ! -d "./run" ]; then
...@@ -64,23 +60,18 @@ start() ...@@ -64,23 +60,18 @@ start()
if [ ! -d ${log_path} ]; then if [ ! -d ${log_path} ]; then
mkdir ${log_path} mkdir ${log_path}
fi fi
log_path=`readlink -f ${log_path}` log_path=$(readlink -f ${log_path})
chmod u+x ./bin/${BIN} && ./bin/${BIN} -f ./conf/conf.json &> ${log_path}/out.log& chmod u+x ./bin/${BIN} && ./bin/${BIN} -f ./conf/conf.json &>${log_path}/out.log &
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
exit -1 exit -1
fi fi
is_running ${deploy_path} ${BIN} is_running
} }
stop() stop() {
{ kill_proc_9
cd `dirname $0`
echo "work path : "`pwd`
deploy_path=`pwd`
kill_proc_9 ${deploy_path} ${BIN}
} }
case C"$1" in case C"$1" in
...@@ -97,11 +88,7 @@ Cdebug) ...@@ -97,11 +88,7 @@ Cdebug)
echo "${BIN} started!" echo "${BIN} started!"
;; ;;
Cstatus) Cstatus)
cd `dirname $0` is_running
echo "work path : "`pwd`
deploy_path=`pwd`
is_running ${deploy_path} ${BIN}
status=$? status=$?
echo "status : ${status}" echo "status : ${status}"
exit ${status} exit ${status}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册