Skip to content

Instantly share code, notes, and snippets.

@alehmann
Created November 12, 2009 03:43
Show Gist options
  • Save alehmann/232573 to your computer and use it in GitHub Desktop.
Save alehmann/232573 to your computer and use it in GitHub Desktop.
rubyrep: system startup script
#! /bin/sh
#
# /etc/init.d/myapp_rep.sh
#
# chkconfig: 35 99 99
# description: Starts or stops the myapp replication
#
# Assumes that application specific files
# * replication launcher script
# * rubyrep configuration file
# * rubyrep log file
# * rubyrep JRuby package
# are kept in /opt/myapp_rep/
case "$1" in
start)
echo "Starting myapp replication"
nohup bash /opt/myapp_rep/replicate 2>&1 |gawk '{print strftime("%Y-%m-%d %T",systime()),$0; fflush();}' >>/opt/myapp_rep/replication.log &
;;
stop)
echo "Shutting down myapp replication"
kill `ps -Af |grep myapp_rep|grep replicate |grep java |awk '{print $2}'`
;;
restart)
$0 stop
$0 start
;;
status)
echo -e "myapp replication \\c"
ps -Af |grep myapp_rep|grep replicate |grep java >/dev/null || echo -e not \\c
echo running
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
;;
esac
#! /bin/sh
#
# Launches rubyrep replication.
#
# Assumes that
# * rubyrep configuration file
# * rubyrep JRuby package
# are kept in /opt/myapp_rep/
bash /opt/myapp_rep/rubyrep/rubyrep replicate -c /opt/myapp_rep/rubyrep.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment