Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 08:39:08

0001 #!/bin/sh
0002 #
0003 # chkconfig: - 85 15
0004 #
0005 # description: Panda MCP
0006 # processname: python
0007 # config: /etc/panda/panda_server.cfg
0008 # pidfile: /var/log/panda/panda_mcp.pid
0009 #
0010 
0011 # When multiple arguments are given, only the error from the _last_
0012 # one is reported.
0013 #
0014 ARGV="$@"
0015 #
0016 # |||||||||||||||||||| START CONFIGURATION SECTION  ||||||||||||||||||||
0017 # --------------------                              --------------------
0018 #
0019 
0020 # virtual env activation
0021 @@virtual_env_setup@@
0022 
0023 # the path to application
0024 PROGNAME='python -u @@install_purelib@@/pandaserver/pandamcp/mcp_main.py'
0025 
0026 # pid and lock files
0027 if [[ -z "${PANDA_LOCK_DIR}" ]]; then
0028     PIDFILE='/var/log/panda/panda_mcp.pid'
0029 else
0030     PIDFILE=${PANDA_LOCK_DIR}'/panda_mcp.pid'
0031 fi
0032 
0033 # log files
0034 LOGSTDOUT='/var/log/panda/panda_mcp_stdout.log'
0035 LOGSTDERR='/var/log/panda/panda_mcp_stderr.log'
0036 
0037 # Source panda server env variables
0038 if [ -r /etc/sysconfig/panda_server ]; then
0039    . /etc/sysconfig/panda_server
0040 fi
0041 
0042 
0043 start() {
0044     echo "Starting PanDA MCP ..."
0045 
0046     # Check if already running
0047     if [ -f "$PIDFILE" ]; then
0048         kill -0 "$(cat "$PIDFILE")" 2>/dev/null
0049         ERROR=$?
0050         if [ $ERROR -eq 0 ]; then
0051             echo "Already running."
0052             return 0
0053         fi
0054     fi
0055 
0056     # Start program in foreground but fork to background manually to free the shell
0057     # while still tracking PID.
0058     nohup $PROGNAME >> $LOGSTDOUT 2>> $LOGSTDERR &
0059     ERROR=$?
0060 
0061     if [ $ERROR -ne 0 ]; then
0062         echo "Failed to start myservice (exit code $ERROR)."
0063         return $ERROR
0064     fi
0065 
0066     echo $! > "$PIDFILE"
0067     echo "PanDA MCP started with PID $(cat "$PIDFILE")."
0068 }
0069 
0070 stop() {
0071     echo "Stopping PanDA MCP ..."
0072 
0073     if [ ! -f "$PIDFILE" ]; then
0074         echo "PID file not found; is PanDA MCP running?"
0075         return 0
0076     fi
0077 
0078     kill "$PID" 2>/dev/null
0079     ERROR=$?
0080 
0081     if [ $ERROR -ne 0 ]; then
0082         echo "Could not stop process (exit code $ERROR)."
0083         return $ERROR
0084     fi
0085 
0086     rm -f "$PIDFILE"
0087     ERROR=$?
0088 
0089     if [ $ERROR -ne 0 ]; then
0090         echo "Could not remove PID file (exit code $ERROR)."
0091         return $ERROR
0092     fi
0093 
0094     echo "Stopped."
0095 }
0096 
0097 status() {
0098     if [ -f "$PIDFILE" ]; then
0099         kill -0 "$(cat "$PIDFILE")" 2>/dev/null
0100         ERROR=$?
0101 
0102         if [ $ERROR -eq 0 ]; then
0103             echo "Running (PID $(cat "$PIDFILE"))."
0104             return 0
0105         fi
0106     fi
0107 
0108     echo "Not running."
0109     return 1
0110 }
0111 
0112 # main
0113 if [ "x$ARGV" = "x" ] ; then
0114     ARGV="-h"
0115 fi
0116 
0117 case $ARGV in
0118     start) start ;;
0119     stop) stop ;;
0120     restart) stop; start ;;
0121     status) status ;;
0122     *)
0123         echo "Usage: $0 {start|stop|restart|status}"
0124         exit 1
0125         ;;
0126 esac
0127 
0128 exit 0