代码拉取完成,页面将自动刷新
同步操作将从 DiDi-opensource/falcon-log-agent 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
workspace=$(cd $(dirname $0) && pwd)
cd $workspace
module=log-agent
app=falcon-$module
conf=cfg/cfg.json
strategyconf=cfg/strategy.json
pidfile=var/app.pid
logfile=log/app.log
mkdir -p var &>/dev/null
mkdir -p log &>/dev/null
function stop_pid() {
pid=$(cat $pidfile)
# 校验pid与进程名是否一致 || 根据进程名获取pid,要求父进程ppid==1(适用于root启动的agent)
ps -p ${pid} | grep -q ${app} || pid=$(ps -o ppid,pid $(pidof ${app}) | awk '$1==1 {print $2}')
if [ -n ${pid} ]; then
kill ${pid} || kill -9 ${pid}
fi
echo "$app stoped... or not start"
}
function start() {
check_pid
running=$?
if [ $running -gt 0 ];then
echo -n "[old process]still running, quit, pid = "
cat $pidfile
else
nohup ./$app -c $conf -s $strategyconf>>$logfile 2>&1 &
echo $! > $pidfile
echo "start ok, pid=$!"
fi
}
function stop() {
kill `get_pid`
for i in `seq 1 20`
do
sleep 1
check_pid
running=$?
if [ $running -gt 0 ];then
echo -n "[restart]still running, wait.. , pid = "
cat $pidfile
if [ $i -gt 10 ]
then
kill -9 `get_pid`
fi
continue
else
echo "stoped"
break
fi
done
}
function restart() {
stop
sleep 1
start
}
function status() {
check_pid
running=$?
if [ $running -gt 0 ];then
echo -n "running, pid="
cat $pidfile
else
echo "stoped"
fi
}
function get_pid() {
if [ -f $pidfile ];then
cat $pidfile
else
pid=`ps aux | grep $app | grep $conf | awk '{print $2}'`
if [ "x_$pid" != "x_" ]; then
echo $pid > $pidfile
cat $pidfile
fi
fi
}
function check_pid() {
pid=`get_pid`
if [ "x_" != "x_$pid" ]; then
running=`ps -p $pid|grep -v "PID TTY" |wc -l`
return $running
fi
return 0
}
action=$1
case $action in
"start" )
start
;;
"stop" )
stop
;;
"restart" )
restart
;;
"status" )
status
;;
esac
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。