2626 PYTHON=" python"
2727fi
2828
29- PACKAGE_PATH=$( " ${PYTHON} " -c " import os; print os.path.dirname(os.path.realpath('$0 '))" )
29+ if [ -L $0 ]; then
30+ PACKAGE_PATH=" $( dirname $( readlink -n $0 ) ) /"
31+ else
32+ PACKAGE_PATH=" ./"
33+ fi
34+ PACKAGE_VER_FILE=" ${PACKAGE_PATH} code/version.txt"
35+ PACKAGE_VER=" default"
36+ if [ -f " ${PACKAGE_VER_FILE} " ]; then
37+ PACKAGE_VER=$( cat $PACKAGE_VER_FILE )
38+ fi
39+ PACKAGE_START=" ${PACKAGE_PATH} code/${PACKAGE_VER} /launcher/start.py"
40+
41+ if ! [ -f $PACKAGE_START ]; then
42+ PACKAGE_START=" ${PACKAGE_PATH} code/default/launcher/start.py"
43+ fi
3044
3145start () {
3246 echo -n " Starting ${PACKAGE_DESC} : "
3347 if hash python2 2> /dev/null; then
34- # nohup "${PYTHON}" launcher/start.py 2>&1 | /usr/bin/logger -t ${PACKAGE_NAME} &
35- nohup " ${PYTHON} " ${PACKAGE_PATH} /launcher/start.py > /dev/null 2>&1 &
48+ nohup " ${PYTHON} " ${PACKAGE_START} > /dev/null 2>&1 &
3649 fi
3750 echo " ${PACKAGE_NAME} ."
3851}
3952
4053stop () {
4154 echo -n " Stopping ${PACKAGE_DESC} : "
42- kill -9 ` ps aux | grep " ${PYTHON} ${PACKAGE_PATH} /launcher/start.py " | grep -v grep | awk ' {print $2}' ` || true
55+ kill -9 ` ps aux | grep " ${PYTHON} ${PACKAGE_START} " | grep -v grep | awk ' {print $2}' ` || true
4356 echo " ${PACKAGE_NAME} ."
4457}
4558
59+ status () {
60+ pid=" PID` ps aux | grep " ${PYTHON} ${PACKAGE_START} " | grep -v grep | awk ' {print $2}' ` "
61+ if [ $pid == " PID" ]; then
62+ echo " xx-net stoped"
63+ else
64+ echo " xx-net running,pid: ${pid## " PID" } "
65+ fi
66+ }
67+
4668restart () {
4769 stop
4870 sleep 1
@@ -51,7 +73,7 @@ restart() {
5173
5274usage () {
5375 N=$( basename " $0 " )
54- echo " Usage: [sudo] $N {start|stop|restart}" >&2
76+ echo " Usage: [sudo] $N {start|stop|restart|status }" >&2
5577 exit 1
5678}
5779
@@ -74,10 +96,12 @@ case "$1" in
7496 restart | force-reload)
7597 restart
7698 ;;
99+ status)
100+ status
101+ ;;
77102 * )
78103 usage
79104 ;;
80105esac
81106
82107exit 0
83- }
0 commit comments