-
-
Save Woody2143/bb2d20ef0d81a3b7ffbf89c0d1bab766 to your computer and use it in GitHub Desktop.
Basic Centos init script for Dancer apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# some_website - this script starts and stops some_website | |
# | |
# chkconfig: - 85 15 | |
# description: Some website description | |
# pidfile: /var/run/plackup.some_website.pid | |
PID=/var/run/plackup.some_website.pid | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
# Source networking configuration. | |
. /etc/sysconfig/network | |
# Check that networking is up. | |
[ "$NETWORKING" = "no" ] && exit 0 | |
PORT=5001 | |
WORKERS=32 | |
DANCER_DIR="/opt/webapps/some_website" | |
DANCER_APP="$DANCER_DIR/bin/app.pl" | |
plackup="/usr/bin/plackup" | |
plackup_args="-E production -p $PORT -s Starman --pid=$PID --workers $WORKERS -D" | |
website="Some Website" | |
lockfile=/var/lock/subsys/plackup.some_website | |
start() { | |
[ -x $plackup ] || exit 5 | |
[ -f $DANCER_APP ] || exit 6 | |
echo -n $"Starting $website: " | |
$plackup $plackup_args -a $DANCER_APP 2>&1 > /dev/null | |
retval=$? | |
if [ $retval -eq 0 ]; then | |
success $"$website started" | |
touch $lockfile | |
else | |
failure $"Unable to start" | |
fi | |
echo | |
return $retval | |
} | |
stop() { | |
echo -n $"Stopping $website: " | |
if [ -f $PID ]; then | |
kill `cat $PID` 2>&1> /dev/null | |
retval=$? | |
[ $retval -eq 0 ] && success && rm -f $lockfile | |
echo | |
return $retval | |
fi | |
failure $"pid $PID not found" | |
echo | |
return 1 | |
} | |
restart() { | |
stop | |
start | |
} | |
case "$1" in | |
start) | |
$1 | |
;; | |
stop) | |
$1 | |
;; | |
restart) | |
$1 | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart}" | |
exit 2 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment