Created
December 29, 2014 21:50
-
-
Save fbettag/7b74e02b787467502077 to your computer and use it in GitHub Desktop.
Simple file to drop into jetty's distribution directory and start a lift application off of
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! luckily this is not used by any server | |
NAME="software name (change in $0)" | |
RAMSIZE=1G | |
BASEPORT=9090 | |
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 | |
RAMSIZE=2G | |
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