Skip to content

Instantly share code, notes, and snippets.

@jldevezas
Created December 15, 2016 13:56
Show Gist options
  • Save jldevezas/8c3b3b6d6babbd0349aeda538956b038 to your computer and use it in GitHub Desktop.
Save jldevezas/8c3b3b6d6babbd0349aeda538956b038 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# /etc/init.d/ant -- startup script for the ANT 0.1-SNAPSHOT search engine
#
# Written by José Devezas <[email protected]>.
#
### BEGIN INIT INFO
# Provides: ant
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start ANT
# Description: Start the ANT search engine platform
### END INIT INFO
ant_home="/opt/ant"
ant_user="jldevezas"
start_search_engine="java -jar ant-search-engine-assembly-0.4-SNAPSHOT.jar engine server 127.0.0.1"
export RAILS_ENV=production
precompile_assets_front_end="bundle exec rake assets:precompile"
start_front_end="bundle exec unicorn -E production -D -c $ant_home/front-end/config/unicorn.rb"
start() {
su $ant_user -c "(cd $ant_home && $start_search_engine 2>/dev/null >/dev/null &)"
su $ant_user -c "(cd $ant_home/front-end && $precompile_assets_front_end 2>/dev/null >/dev/null &)"
su $ant_user -c "(cd $ant_home/front-end && $start_front_end)"
return 0
}
stop() {
if [ -r "$ant_home/run/ant-search-engine.pid" ]
then
su $ant_user -c "kill `cat $ant_home/run/ant-search-engine.pid`"
fi
if [ -r "$ant_home/run/ant-front-end.pid" ]
then
su $ant_user -c "kill `cat $ant_home/run/ant-front-end.pid`"
fi
return 0
}
case "$1" in
start)
echo "Starting ANT platform..."
start
;;
stop)
echo "Stopping ANT platform..."
stop
;;
restart)
echo "Restarting ANT platform..."
stop && start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment