1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/cnperl-falcon-agent

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
В этом репозитории не указан файл с открытой лицензией (LICENSE). При использовании обратитесь к конкретному описанию проекта и его зависимостям в коде.
Клонировать/Скачать
control 1.3 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Ulric Qin Отправлено 15.12.2014 14:01 2d3186d
#!/bin/bash
WORKSPACE=$(cd $(dirname $0)/; pwd)
cd $WORKSPACE
mkdir -p var
module=agent
app=falcon-$module
conf=cfg.json
pidfile=var/app.pid
logfile=var/app.log
[[ -f $app ]] || mv $module $app
[[ -f $conf ]] || cp cfg.example.json $conf
function check_pid() {
if [ -f $pidfile ];then
pid=`cat $pidfile`
if [ -n $pid ]; then
running=`ps -p $pid|grep -v "PID TTY" |wc -l`
return $running
fi
fi
return 0
}
function start() {
check_pid
running=$?
if [ $running -gt 0 ];then
echo -n "$app now is running already, pid="
cat $pidfile
return 1
fi
nohup ./$app -c $conf &> $logfile &
echo $! > $pidfile
echo "$app started..., pid=$!"
}
function stop() {
pgrep $app | xargs kill &>/dev/null
echo "$app stoped..."
}
function restart() {
stop
sleep 1
start
}
function status() {
check_pid
running=$?
if [ $running -gt 0 ];then
echo -n "$app now is running, pid="
cat $pidfile
else
echo "$app is stoped"
fi
}
function help() {
echo "$0 start|stop|restart|status"
}
if [ "$1" == "" ]; then
help
elif [ "$1" == "stop" ];then
stop
elif [ "$1" == "start" ];then
start
elif [ "$1" == "restart" ];then
restart
elif [ "$1" == "status" ];then
status
else
help
fi

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/cnperl-falcon-agent.git
git@api.gitlife.ru:oschina-mirror/cnperl-falcon-agent.git
oschina-mirror
cnperl-falcon-agent
cnperl-falcon-agent
master