Created
September 13, 2015 16:56
-
-
Save davinkevin/9c90ee0e6487d987aa54 to your computer and use it in GitHub Desktop.
init.d script podcast-server
This file contains 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/bash | |
# | |
# Podcast-Server This shell script takes care of starting and stopping Tomcat | |
# | |
# chkconfig: - 80 20 | |
# | |
### BEGIN INIT INFO | |
# Provides: podcast-server | |
# Required-Start: $network $syslog | |
# Required-Stop: $network $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Description: Podcast Server implementation | |
# Short-Description: start and stop Podcast-Server | |
### END INIT INFO | |
NAME="Podcast Server" | |
JAVA_HOME=/usr/lib/jvm/java-8-oracle | |
SPRING_BOOT_LOCATION=/opt/podcast-server | |
USER=podcast-server | |
APPLICATION=Podcast-Server | |
LOCK="$SPRING_BOOT_LOCATION/$APPLICATION.lock" | |
cd $SPRING_BOOT_LOCATION; | |
pid_of_spring_boot() { | |
pgrep -f "java.*$APPLICATION" | |
} | |
start() { | |
echo -ne "Starting $NAME. " | |
su $USER -c "java -jar $APPLICATION.jar &" &> /dev/null | |
echo | |
} | |
stop() { | |
echo -ne "Stopping $NAME. " | |
pid=`pid_of_spring_boot` | |
[ -n "$pid" ] && kill $pid &> /dev/null | |
sleep 5; | |
echo | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
sleep 10; | |
start | |
;; | |
*) | |
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