update bot script again

This commit is contained in:
Ben Harris 2017-05-01 07:47:07 -04:00
parent 467e9741ad
commit ec1fcff534
1 changed files with 13 additions and 14 deletions

27
bot
View File

@ -2,17 +2,16 @@
source .env source .env
# pid=$(ps -ef | grep BenBot | grep -v grep | awk '{print $2}')
pid=$(pidof $WHICHBOT) pid=$(pidof $WHICHBOT)
case "$1" in case "$1" in
nohup) nohup)
if [ $pid ]; then if [ $pid ]; then
echo "starting BenBot in background (nohup)" echo "${WHICHBOT} already running"
nohup php run.php $WHICHBOT > bot.out 2> bot.err < /dev/null &
else else
echo "BenBot already running" echo "starting ${WHICHBOT} in background (nohup)"
nohup php run.php > bot.out 2> bot.err < /dev/null &
fi fi
;; ;;
@ -25,25 +24,24 @@ case "$1" in
stop) stop)
if [ $pid ]; then if [ $pid ]; then
echo "killing BenBot ($pid)" echo "killing ${WHICHBOT} ($pid)"
kill $pid kill $pid
fi fi
;; ;;
status) status)
#pgrep BenBot && echo "Running"
if [ $pid ]; then if [ $pid ]; then
echo "BenBot running with pid $pid" echo "${WHICHBOT} running with pid $pid"
else else
echo "BenBot not running" echo "${WHICHBOT} not running"
fi fi
;; ;;
log) log)
if [ $pid ]; then if [ $pid ]; then
less bot.out less bot.out
else else
echo "BenBot not running" echo "${WHICHBOT} not running"
fi fi
;; ;;
@ -62,17 +60,17 @@ case "$1" in
sync) sync)
rsync -av ben@benharris.ch:workspace/benbot/uploaded_images/ uploaded_images/ rsync -av ben@benharris.ch:workspace/benbot/uploaded_images/ uploaded_images/
rsync -av ben@benharris.ch:workspace/benbot/bot_data/ bot_data/ rsync -av ben@benharris.ch:workspace/benbot/bot_data/ bot_data/
;; ;;
restart) restart)
if [ $pid ]; then if [ $pid ]; then
echo "killing BenBot ($pid)" echo "killing ${WHICHBOT} ($pid)"
kill $pid kill $pid
fi fi
echo "starting BenBot in background (nohup)" echo "starting ${WHICHBOT} in background (nohup)"
nohup php run.php $WHICHBOT > bot.out 2> bot.err < /dev/null & nohup php run.php > bot.out 2> bot.err < /dev/null &
;; ;;
@ -81,3 +79,4 @@ case "$1" in
exit 1 exit 1
esac esac