First commit
This commit is contained in:
Executable
+92
@@ -0,0 +1,92 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# enserver Start/Stop the EN-Server daemon
|
||||
#
|
||||
# chkconfig: 345 96 10
|
||||
# description: Apsheronsk transport system
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: enserver
|
||||
# Required-Start: $local_fs $network
|
||||
# Required-Stop: $local_fs $network
|
||||
# Short-Description: enserver daemon
|
||||
# Description: Apsheronsk transport system
|
||||
### END INIT INFO
|
||||
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
#set -e
|
||||
# This is an interactive program, we need the current locale
|
||||
[ -f /etc/profile.d/lang.sh ] && . /etc/profile.d/lang.sh
|
||||
|
||||
if [ -f /etc/sysconfig/enserver ]; then
|
||||
. /etc/sysconfig/enserver
|
||||
fi
|
||||
|
||||
# configuration parameters
|
||||
PYTHON=${PYTHON:-/usr/bin/python2.6}
|
||||
ENSERVER=${ENSERVER:-/usr/lib/python2.6/site-packages/enserver/enserver.py}
|
||||
USER=${USER:-apsh}
|
||||
PIDFILE=${PIDFILE:-/var/run/apsh/enserver.pid}
|
||||
STOP_TIMEOUT=${STOP_TIMEOUT:-10}
|
||||
HTTP_PORT=${HTTP_PORT:-7000}
|
||||
TCP_PORT=${TCP_PORT:-7001}
|
||||
LOGLEVEL=${LOGLEVEL:+--debug}
|
||||
LOGFILE=${LOGFILE:-/var/log/apsh/enserver.log}
|
||||
STORAGE=${STORAGE:-/share/store/enserver}
|
||||
PARENT_HOST=${HOST:+--host=$HOST}
|
||||
ADDRESS=${ADDRESS:-enserv}
|
||||
RETVAL=0
|
||||
|
||||
OPTIONS="$LOGLEVEL --logfile=$LOGFILE --port=$TCP_PORT --pidfile=$PIDFILE --storage=$STORAGE --address=$ADDRESS $PARENT_HOST $OPTIONS"
|
||||
DAEMON="--daemon"
|
||||
|
||||
start() {
|
||||
echo -n $"Starting enserver: "
|
||||
|
||||
LANG="C" ss -pltn | grep ":${HTTP_PORT}[ \t]\+" > /dev/null && P1=0 || P1=1
|
||||
LANG="C" ss -pltn | grep ":${TCP_PORT}[ \t]\+" > /dev/null && P2=0 || P2=1
|
||||
|
||||
if [ $P1 -eq 0 ] || [ $P2 -eq 0 ]; then
|
||||
echo -n $"port already in use"
|
||||
RETVAL=1
|
||||
else
|
||||
daemon --user=${USER} --pidfile=${PIDFILE} $PYTHON $ENSERVER $DAEMON $OPTIONS
|
||||
RETVAL=$?
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping enserver: "
|
||||
killproc -p ${PIDFILE} -d ${STOP_TIMEOUT} $PYTHON
|
||||
RETVAL=$?
|
||||
echo
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
constart)
|
||||
DAEMON=""
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
status)
|
||||
status -p ${PIDFILE} $PYTHON
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart}"
|
||||
RETVAL=2
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
Reference in New Issue
Block a user