Skip to content

Commit

Permalink
Change layout
Browse files Browse the repository at this point in the history
  • Loading branch information
springhack committed Nov 3, 2016
1 parent 6bc5ca0 commit 40719d6
Show file tree
Hide file tree
Showing 7 changed files with 815 additions and 699 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "libs/lo-runner"]
path = libs/lo-runner
url = https://github.com/springhack/Lo-runner.git
path = libs/lo-runner
url = https://github.com/springhack/Lo-runner.git
152 changes: 96 additions & 56 deletions ajcserver/ajcd
Original file line number Diff line number Diff line change
Expand Up @@ -15,73 +15,113 @@
### END INIT INFO

# Author: SpringHack
# website: http://blog.90its.cn/
# website: http://www.dosk.win/

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=ajcd
NGINX_BIN=/home/AJC/ajcserver/$NAME.py
AJCD_BIN=/home/AJC/ajcserver/$NAME.py
PID=`ps axu | grep ^root.*ajcd.py$ | awk -F ' ' '{print $2}'`


case "$1" in
start)
echo -n "Starting $NAME... "

if [ "${PID}xx" != "xx" ];
then
echo "$NAME is running."
exit 1
fi

python $NGINX_BIN &

sleep 2

PID=`ps axu | grep ^root.*ajcd.py$ | awk -F ' ' '{print $2}'`

if [ "${PID}xx" != "xx" ];
then
echo "done"
else
echo "failed"
exit 1
fi
;;
echo "Starting $NAME... "

if [ "${PID}xx" != "xx" ];
then
echo "$NAME is running.";
exit 0;
fi

python $AJCD_BIN &
sleep 2

PID=`ps axu | grep ^root.*ajcd.py$ | awk -F ' ' '{print $2}'`
if [ "${PID}xx" != "xx" ];
then
echo "done";
else
echo "failed";
exit 1;
fi
;;

stop)
echo -n "Stoping $NAME... "

if [ "${PID}xx" != "xx" ];
then
sleep 0
else
echo "$NAME is not running."
exit 1
fi

kill -9 $PID 2>&1 1>/dev/null

PID=`ps axu | grep ^root.*ajcd.py$ | awk -F ' ' '{print $2}'`

if [ "${PID}xx" != "xx" ];
then
echo "failed"
exit 1
else
echo "done"
fi
;;
echo "Stoping $NAME... "

if [ "${PID}xx" != "xx" ];
then
sleep 0;
else
echo "$NAME is not running.";
exit 1;
fi

PID=`ps axu | grep ^root.*runner.py.*sock$ | awk -F ' ' '{print $2}'`
if [ "${PID}xx" != "xx" ];
then
for p in $PID;
do
echo "Killing judger ${p}...";
kill -9 $p 1>/dev/null 2>&1;
done
fi

PID=`ps axu | grep ^root.*main_runner.py$ | awk -F ' ' '{print $2}'`
if [ "${PID}xx" != "xx" ];
then
for p in $PID;
do
echo "Killing producer ${i}...";
kill -9 $p 1>/dev/null 2>&1;
done
fi

echo 'Killing main process...'
kill -9 $PID 1>/dev/null2>&1

PID=`ps axu | grep ^root.*ajcd.py$ | awk -F ' ' '{print $2}'`

if [ "${PID}xx" != "xx" ];
then
echo "failed";
exit 1;
else
echo "done";
fi
;;

status)
if [ "${PID}xx" != "xx" ];
then
echo "$NAME (pid $PID) is running..."
exit 1
else
echo "$NAME is stopped"
exit 0
fi
;;
echo "Checking infomation ..."
RET=0
if [ "${PID}xx" != "xx" ];
then
echo "$NAME (pid $PID) is running...";
else
echo "$NAME is stopped";
RET=1
fi
PID=`ps axu | grep ^root.*runner.py.*sock$ | awk -F ' ' '{print $2}'`
if [ "${PID}xx" != "xx" ];
then
for p in $PID;
do
echo "$NAME judger (pid ${p}) is running...";
done
else
echo "$NAME judger is stopped";
RET=1
fi
PID=`ps axu | grep ^root.*main_runner.py$ | awk -F ' ' '{print $2}'`
if [ "${PID}xx" != "xx" ];
then
echo "$NAME producer (pid $PID) is running...";
else
echo "$NAME producer is stopped";
RET=1
fi
exit $RET
;;

restart)
$0 stop
Expand All @@ -92,6 +132,6 @@ case "$1" in
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
;;

esac
Loading

0 comments on commit 40719d6

Please sign in to comment.