Last active
August 29, 2015 13:57
-
-
Save TLmaK0/9648683 to your computer and use it in GitHub Desktop.
Init.d script that I uses to start akka as daemon in Centos 6.4
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
#!/bin/sh | |
# | |
# description | |
# | |
# chkconfig: 3 95 4 | |
# description: description | |
### BEGIN INIT INFO | |
# Provides: | |
# Required-Start: | |
# Required-Stop: | |
# Should-Start: | |
# Should-Stop: | |
# Default-Start: | |
# Default-Stop: | |
# Short-Description: | |
# Description: | |
### END INIT INFO | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
prog="test-service" | |
class="YourAkkaMainClass" | |
AKKA_HOME="/var/lib/project/target/dist" | |
AKKA_CLASSPATH="$AKKA_HOME/config:$AKKA_HOME/lib/*" | |
JAVA_OPTS="-Xms128M -Xmx256M -Xss1M -XX:MaxPermSize=256M -XX:+UseParallelGC" | |
exec="java $JAVA_OPTS -cp \"$AKKA_CLASSPATH\" -Dakka.home=\"$AKKA_HOME\" akka.kernel.Main \"$class\"" | |
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog | |
lockfile=/var/lock/subsys/$prog | |
start() { | |
echo -n $"Starting $prog: " | |
daemon "$exec >> /var/log/${prog}.log 1>&1 &" | |
retval=$? | |
pid=`ps x -o "%p ;;; %a" | awk '{FS = " ;;; "; if ($2 ~ " '${class}'$") {print $1};}'` | |
if [ -n "$pid" ]; then | |
echo $pid > "/var/run/${prog}.pid" | |
fi | |
echo | |
[ $retval -eq 0 ] && touch $lockfile | |
return $retval | |
} | |
stop() { | |
echo -n $"Stopping $prog: " | |
killproc -p /var/run/${prog}.pid | |
retval=$? | |
echo | |
[ $retval -eq 0 ] && rm -f $lockfile /var/run/$prog.pid | |
return $retval | |
} | |
restart() { | |
stop | |
start | |
} | |
reload() { | |
restart | |
} | |
force_reload() { | |
restart | |
} | |
rh_status() { | |
status $prog | |
} | |
rh_status_q() { | |
rh_status >/tmp/status 2>&1 | |
} | |
case "$1" in | |
start) | |
rh_status_q && exit 0 | |
$1 | |
;; | |
stop) | |
rh_status_q || exit 0 | |
$1 | |
;; | |
restart) | |
$1 | |
;; | |
reload) | |
rh_status_q || exit 7 | |
$1 | |
;; | |
force-reload) | |
force_reload | |
;; | |
status) | |
rh_status | |
;; | |
condrestart|try-restart) | |
rh_status_q || exit 0 | |
restart | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" | |
exit 2 | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment