Skip to content

Instantly share code, notes, and snippets.

@thesmith
Created March 15, 2011 13:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thesmith/870738 to your computer and use it in GitHub Desktop.
Save thesmith/870738 to your computer and use it in GitHub Desktop.
shell script to start jetty
#! /bin/sh
cd `dirname "$0"`
USER=`whoami`
if [ $USER != 'jetty' ]
then
sudo -u jetty $0 $@
exit $?
fi
case "$1" in
start)
if [ -f "./jetty.pid" ]
then
echo "Already running"
exit 1
fi
nohup java -XX:MaxDirectMemorySize=1G -Xmx2G -Xms256m -DMBST_PLATFORM=prod -Dserver.port=8080 -jar leaf.jar > log &
echo $! > ./jetty.pid
;;
stop)
if [ -f "./jetty.pid" ];
then
pid=`cat ./jetty.pid`
kill $pid
sleep 2
ps -p $pid > /dev/null
if [ $? -eq 0 ];
then
kill -9 $pid
fi
rm ./jetty.pid
else
echo "Process wasn't running"
fi
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment