Mercurial > libervia-backend
comparison src/sat.sh @ 1151:02c26e6630d0
misc (launch script): added a "status" command
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 03 Sep 2014 11:46:09 +0200 |
parents | 9ae01ccf89c1 |
children | 61c03265e133 |
comparison
equal
deleted
inserted
replaced
1150:beaf8d4475e4 | 1151:02c26e6630d0 |
---|---|
51 PYTHONEND | 51 PYTHONEND |
52 ` | 52 ` |
53 APP_NAME="$APP_NAME" | 53 APP_NAME="$APP_NAME" |
54 PID_FILE="$PID_DIR$APP_NAME_FILE.pid" | 54 PID_FILE="$PID_DIR$APP_NAME_FILE.pid" |
55 LOG_FILE="$LOG_DIR$APP_NAME_FILE.log" | 55 LOG_FILE="$LOG_DIR$APP_NAME_FILE.log" |
56 RUNNING_MSG="$APP_NAME is running" | |
57 NOT_RUNNING_MSG="$APP_NAME is *NOT* running" | |
56 | 58 |
57 # if there is one argument which is "stop", then we kill SàT | 59 # if there is one argument which is "stop", then we kill SàT |
58 if [ $# -eq 1 ];then | 60 if [ $# -eq 1 ];then |
59 if [ $1 = "stop" ];then | 61 if [ $1 = "stop" ];then |
60 kill_process $PID_FILE "$APP_NAME" | 62 kill_process $PID_FILE "$APP_NAME" |
63 echo "Launching $APP_NAME in debug mode" | 65 echo "Launching $APP_NAME in debug mode" |
64 DEBUG="--debug" | 66 DEBUG="--debug" |
65 elif [ $1 = "fg" ];then | 67 elif [ $1 = "fg" ];then |
66 echo "Launching $APP_NAME in foreground mode" | 68 echo "Launching $APP_NAME in foreground mode" |
67 DAEMON="n" | 69 DAEMON="n" |
70 elif [ $1 = "status" ];then | |
71 if [ -f $PID_FILE ]; then | |
72 PID=`cat $PID_FILE` | |
73 ps -p$PID 2>&1 > /dev/null | |
74 if [ $? = 0 ];then | |
75 echo "$RUNNING_MSG (pid: $PID)" | |
76 exit 0 | |
77 else | |
78 echo "$NOT_RUNNING_MSG, but a pid file is present (bad exit ?): $PID_FILE" | |
79 exit 2 | |
80 fi | |
81 else | |
82 echo "$NOT_RUNNING_MSG" | |
83 exit 1 | |
84 fi | |
85 else | |
86 echo "bad argument, please use one of (stop, debug, fg, status) or no argument" | |
87 exit 1 | |
68 fi | 88 fi |
69 fi | 89 fi |
70 | 90 |
71 MAIN_OPTIONS="-${DAEMON}o" | 91 MAIN_OPTIONS="-${DAEMON}o" |
72 | 92 |