Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Debian based on boot Kete supporting processes.
#!/bin/bash
### BEGIN INIT INFO
# Provides: kbzb
# Required-Start: $mysql $all
# Required-Stop: $mysql
# Default-Start: 2
# Default-Stop:
# Short-Description: Reboot all Backgroundrb and Zebra for Kete instances
### END INIT INFO
RUBY_BIN=/opt/ree-latest/bin # adjust this to the path of your REE bin directory
DEPLOYED_KETE="your_app"
NON_DEPLOYED_KETE="your_non_deployed_app"
LOG_FILE="/home/kete/reboot.log"
# DO NOT EDIT PAST THIS POITN
set -e
PATH=$RUBY_BIN:/bin:/usr/bin:/sbin:/usr/sbin:$PATH
function start_backgroundrb_and_zebra {
log ""; log "Starting zebra and background - `date +%Y-%m-%d`"
/bin/su -c "chown kete:kete $LOG_FILE"
for app in `echo $DEPLOYED_KETE`; do start_up "/home/kete/apps/${app}/current"; done
for app in `echo $NON_DEPLOYED_KETE`; do start_up "/home/kete/apps/${app}"; done
/bin/su -c "chown kete:kete $LOG_FILE"
}
function stop_backgroundrb_and_zebra {
killall zebrasrv
killall ruby
}
function start_up {
log ""; log "Starting up Zebra and BackgroundRB for $1"
# su command strips PATH from env, thus we have to specify full path to ruby commands
/bin/su -l kete -c "/usr/bin/env $RUBY_BIN/ruby '$1/script/backgroundrb' start >> $LOG_FILE" kete - kete
/bin/su -l kete -c "/usr/bin/env $RUBY_BIN/rake -f '$1/Rakefile' '$1/' zebra:start >> $LOG_FILE" kete - kete
}
function log {
echo $1 >> $LOG_FILE
}
case "$1" in
start)
start_backgroundrb_and_zebra
;;
stop)
stop_backgroundrb_and_zebra
;;
restart | reboot | reload)
stop_backgroundrb_and_zebra
start_backgroundrb_and_zebra
;;
*)
echo "Usage: /etc/init.d/kete_backgroundrb_and_zebra_boot {start|stop|restart|reboot}" >&2
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.