Skip to content
Snippets Groups Projects
Commit 0990b1f6 authored by Tomáš Plesník's avatar Tomáš Plesník
Browse files

skript prepsan do jednotlivych funkci; mezi stopnutim a startem serveru pri...

skript prepsan do jednotlivych funkci; mezi stopnutim a startem serveru pri restartu pridano 1s cekani
parent 8789ffd7
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
# otherwise) arising in any way out of the use of this software, even # otherwise) arising in any way out of the use of this software, even
# if advised of the possibility of such damage. # if advised of the possibility of such damage.
WARDEN="/opt/warden-server/bin/warden-server.pl" WARDEN="/opt/warden-server/bin/warden-server.pl"
PID_FILE="/var/run/warden-server.pl.pid" PID_FILE="/var/run/warden-server.pl.pid"
LOCK_FILE="/var/lock/warden-server" LOCK_FILE="/var/lock/warden-server"
...@@ -47,6 +46,12 @@ if [ -z $WARDEN ]; then ...@@ -47,6 +46,12 @@ if [ -z $WARDEN ]; then
exit 1 exit 1
fi fi
usage() {
echo "Usage: $0 [start|stop|status|restart|force-stop]"
exit 1
}
check_status() { check_status() {
/bin/ps axo pid,comm | grep -q "warden-server*"; RET_VAL=`echo $?` /bin/ps axo pid,comm | grep -q "warden-server*"; RET_VAL=`echo $?`
if [ $RET_VAL -eq 0 ]; then if [ $RET_VAL -eq 0 ]; then
...@@ -61,64 +66,79 @@ get_pid() { ...@@ -61,64 +66,79 @@ get_pid() {
return $PID return $PID
} }
case $1 in warden_start() {
status) check_status
check_status if [ $STATUS -eq 1 ]; then
if [ $STATUS -eq 1 ]; then get_pid PID
get_pid PID echo "Warden daemon is running (pid $PID)."
echo "Warden daemon is running (pid $PID)." else
echo "Starting Warden server daemon ..."
$WARDEN
touch $LOCK_FILE
fi
}
warden_stop() {
check_status
if [ $STATUS -eq 1 ]; then
echo "Stoping Warden server daemon ..."
if [ -e $PID_FILE ]; then
PID=`cat $PID_FILE`
kill -1 $PID
rm -f $LOCK_FILE
else else
echo "Warden daemon is NOT running." echo "Unable to stop Warden server daemon. Try to use: $SCRIPTNAME force-stop"
fi
else
echo "Warden daemon is NOT running."
fi
}
warden_status() {
check_status
if [ $STATUS -eq 1 ]; then
get_pid PID
echo "Warden daemon is running (pid $PID)."
else
echo "Warden daemon is NOT running."
fi
}
warden_force_stop() {
check_status
if [ $STATUS -eq 1 ]; then
echo "Force stoping Warden server daemon ..."
get_pid PID
kill -9 $PID
if [ -e $PID_FILE ]; then
rm -f $PID_FILE
fi fi
rm -f $LOCK_FILE
else
echo "Warden daemon is NOT running."
fi
}
case $1 in
status)
warden_status
;; ;;
start) start)
check_status warden_start
if [ $STATUS -eq 1 ]; then
get_pid PID
echo "Warden daemon is running (pid $PID)."
else
echo "Starting Warden server daemon ..."
$WARDEN
touch $LOCK_FILE
fi
;; ;;
stop) stop)
check_status warden_stop
if [ $STATUS -eq 1 ]; then
echo "Stoping Warden server daemon ..."
if [ -e $PID_FILE ]; then
PID=`cat $PID_FILE`
kill -1 $PID
rm -f $LOCK_FILE
else
echo "Unable to stop Warden server daemon. Try to use: $SCRIPTNAME force-stop"
fi
else
echo "Warden daemon is NOT running."
fi
;; ;;
force-stop) force-stop)
check_status warden_force_stop
if [ $STATUS -eq 1 ]; then
echo "Force stoping Warden server daemon ..."
get_pid PID
kill -9 $PID
if [ -e $PID_FILE ]; then
rm -f $PID_FILE
fi
rm -f $LOCK_FILE
else
echo "Warden daemon is NOT running."
fi
;; ;;
restart) restart)
$0 stop warden_stop
$0 start sleep 1
warden_start
;; ;;
*) *)
# Display usage of this script usage
echo "Usage: $0 [start|stop|status|restart|force-stop]"
exit 1
;; ;;
esac esac
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment