Mercurial > libervia-web
comparison src/libervia.sh @ 561:160b45937ed2
misc: launch script now manage "status" command, and additional arguments
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 03 Oct 2014 18:13:48 +0200 |
parents | 750db9ff8525 |
children | 7e8356479fef |
comparison
equal
deleted
inserted
replaced
560:77bf2654ca0a | 561:160b45937ed2 |
---|---|
48 env.append("APP_NAME='%s'" % C.APP_NAME) | 48 env.append("APP_NAME='%s'" % C.APP_NAME) |
49 env.append("APP_NAME_FILE='%s'" % C.APP_NAME_FILE) | 49 env.append("APP_NAME_FILE='%s'" % C.APP_NAME_FILE) |
50 print ";".join(env) | 50 print ";".join(env) |
51 PYTHONEND | 51 PYTHONEND |
52 ` | 52 ` |
53 APP_NAME="$APP_NAME" | |
53 PID_FILE="$PID_DIR$APP_NAME_FILE.pid" | 54 PID_FILE="$PID_DIR$APP_NAME_FILE.pid" |
54 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" | |
55 | 58 |
56 # if there is one argument which is "stop", then we kill Libervia | 59 # if there is one argument which is "stop", then we kill Libervia |
57 if [ $# -eq 1 ];then | 60 if [ $# -eq 1 ];then |
58 if [ $1 = "stop" ];then | 61 if [ $1 = "stop" ];then |
59 kill_process $PID_FILE "$APP_NAME" | 62 kill_process $PID_FILE "$APP_NAME" |
62 echo "Launching $APP_NAME in debug mode" | 65 echo "Launching $APP_NAME in debug mode" |
63 DEBUG="--debug" | 66 DEBUG="--debug" |
64 elif [ $1 = "fg" ];then | 67 elif [ $1 = "fg" ];then |
65 echo "Launching $APP_NAME in foreground mode" | 68 echo "Launching $APP_NAME in foreground mode" |
66 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 | |
67 fi | 88 fi |
68 fi | 89 fi |
69 | 90 |
70 | 91 |
71 #Don't change the next lines | 92 #Don't change the next lines |
79 log_dir=`dirname "$LOG_FILE"` | 100 log_dir=`dirname "$LOG_FILE"` |
80 if [ ! -d $log_dir ] ; then | 101 if [ ! -d $log_dir ] ; then |
81 mkdir $log_dir | 102 mkdir $log_dir |
82 fi | 103 fi |
83 | 104 |
84 twistd $MAIN_OPTIONS $ADDITIONAL_OPTIONS $APP_NAME_FILE $PLUGIN_OPTIONS | 105 shift |
106 | |
107 twistd $MAIN_OPTIONS $ADDITIONAL_OPTIONS $APP_NAME_FILE $PLUGIN_OPTIONS $@ |