Skip to content

Instantly share code, notes, and snippets.

@didyhu
Last active May 11, 2016 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save didyhu/336e2204128294eb4547 to your computer and use it in GitHub Desktop.
Save didyhu/336e2204128294eb4547 to your computer and use it in GitHub Desktop.
scripts to run spring boot application
#!/bin/bash
stop(){
for pid in $(ps aux | grep 'java' | grep -v 'grep' | awk '{print $2}')
do
pwd=$(pwd);
cwd=$(readlink /proc/$pid/cwd)
if [ ${cwd} -ef ${pwd} ]
then
echo "killing $pid @ $pwd"
kill $pid
fi
done
}
start(){
(java -cp target org.springframework.boot.loader.JarLauncher &)
}
status(){
for pid in $(ps aux | grep 'java' | grep -v 'grep' | awk '{print $2}')
do
pwd=$(pwd);
cwd=$(readlink /proc/$pid/cwd)
if [ ${cwd} -ef ${pwd} ]
then
echo "status of $pid @ $pwd"
ps aux | grep $pid | grep -v "grep"
fi
done
}
case "$1" in
start) start ;;
stop) stop ;;
restart)
stop
start
;;
status) status ;;
*)
echo "Usage: $0 start|stop|restart|status"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment