Added que init script #2724

This commit is contained in:
Priit Tark 2015-07-01 14:10:49 +03:00
parent a2e6603ecc
commit 2324d08394
18 changed files with 178 additions and 293 deletions

46
doc/que/README.md Normal file
View file

@ -0,0 +1,46 @@
Registry que server
===================
Que server responsibilites:
* handle write type of communication between Registrant and Registry
* handle future jobs for Registry
* handle heavy load jobs for Registry
Installation
------------
Que can deploy either separaetly or along to Registry server depends on real load situation.
In both serarious que requires working Registry deployment and full access to Registry databases.
Installation at deployed server:
cd /home/registry/registry/current
sudo cp doc/que/que-init-example /etc/init.d/que # and edit it
sudo chmod +x /etc/init.d/que
sudo /etc/init.d/que # for help and other commands
sudo /etc/init.d/que start # for manual start
sudo update-rc.d que defaults # for start in server boot
# Debugging
You can run que manually as well:
cd /home/registry/registry/current
For all manual que tasks:
RAILS_ENV=production bundle exec rake -T que # for all que tasks for manual control
rake que:clear # Clear Que's job table
rake que:drop # Drop Que's job table
rake que:migrate # Migrate Que's job table to the most recent version (creating it if it doesn't exist)
rake que:work # Process Que's jobs using a worker pool
For all que daemon tasks what inist script uses
RAILS_ENV=production bundle exec rake -T daemon # for all que daemon tasks what init script uses
rake daemon:que # Start que script
rake daemon:que:restart # Restart que daemon
rake daemon:que:start # Start que daemon
rake daemon:que:status # Status que daemon
rake daemon:que:stop # Stop que daemon

51
doc/que/que-init-example Normal file
View file

@ -0,0 +1,51 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: Registry que server
# Required-Start: $all
# Required-Stop: $network $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Enable Registry que server
### END INIT INFO
set -u
set -e
#
# Change these to match your server:
#
# Make sure that all paths are correct.
#
APP_HOME="/home/registry/registry"
APP_ROOT="$APP_HOME/current"
QUE_USER=registry # or use some other unprivileged system user
RAILS_ENV=production
RUBY_BUNDLE_PATH=/home/$QUE_USER/.rbenv/shims/bundle
QUE_INSTANCES=1 # or as many really needed based real load
cd $APP_ROOT || exit 1
case ${1-help} in
status)
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE_PATH exec rake daemon:que:status
;;
start)
echo "$1 que monitor and server"
for i in `seq 1 $QUE_INSTANCES`; do
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE_PATH exec rake daemon:que:start
echo '.'
done
;;
stop)
echo "$1 que monitor and server"
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE_PATH exec rake daemon:que:stop
;;
restart)
echo "$1 que monitor and server"
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE_PATH exec rake daemon:que:restart
;;
*)
echo >&2 "Usage: $0 <status|start|stop|restart>"
exit 1
;;
esac