Created
June 22, 2014 21:13
-
-
Save fbettag/447d63940ef5370fd410 to your computer and use it in GitHub Desktop.
Liftweb Jetty run-script. Download a standard jetty dist tarball, extract it, put this script into the folder, update the variables at the top, copy your .war-file to webapps/ and run it.
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
#!/usr/bin/env bash | |
# yeah this really needs a bash! | |
NAME="lift project (change this in $0)" | |
RAMSIZE=256M | |
BASEPORT=8040 | |
USAGE="Usage: $0 [start|stop] [dev|prev|prod]" | |
if [ $# -ne 2 ]; then echo $USAGE && exit 1; fi | |
case "$2" in | |
dev*) | |
UPPORT=2 | |
MODE=development | |
LOGSUFFIX= | |
;; | |
prev*) | |
UPPORT=1 | |
MODE=preview | |
LOGSUFFIX= | |
;; | |
prod*) | |
UPPORT=0 | |
MODE=production | |
LOGSUFFIX=.prod | |
;; | |
*) | |
echo $USAGE && exit 1 | |
esac | |
# switch to jetty home where this script is located | |
export JETTY_HOME=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd) | |
cd $JETTY_HOME | |
PORT=$(expr $BASEPORT + $UPPORT) | |
PIDFILE=${MODE}.pid | |
case "$1" in | |
start) | |
echo "Starting jetty for '$NAME' at $PORT with $RAMSIZE in mode $MODE" | |
nohup java -Xmx${RAMSIZE} -Drun.mode=${MODE} \ | |
-Djetty.port=$PORT -Djetty.home=$JETTY_HOME \ | |
-jar start.jar >> logs/std${LOGSUFFIX}.out 2>> logs/err${LOGSUFFIX}.out & | |
echo $! > ${PIDFILE} | |
echo "The PID is $!" | |
;; | |
stop) | |
echo "Stopping jetty for '$NAME' at $PORT with $RAMSIZE in mode $MODE" | |
kill -9 $(cat ${PIDFILE}) | |
rm ${PIDFILE} | |
;; | |
restart) | |
$0 stop $2 | |
$0 start $2 | |
;; | |
*) | |
echo $USAGE && exit 1 | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment