Que inits script sudo friendly, pid files moved to tmp/pids #2724

This commit is contained in:
Priit Tark 2015-07-16 18:42:49 +03:00
parent 9d22212acd
commit 463df1f406
4 changed files with 31 additions and 17 deletions

View file

@ -22,9 +22,15 @@ Installation at deployed server:
sudo /etc/init.d/que start # for manual start
sudo update-rc.d que defaults # for start in server boot
# Debugging
PID files
---------
You can run que manually as well:
All pid files are at tmp/pids directory.
Debugging
---------
You can run que manually as well for debugging:
cd /home/registry/registry/current

View file

@ -11,38 +11,35 @@
set -u
set -e
#
# Change these to match your server:
#
# Make sure that all paths are correct.
#
### CHANGES
APP_HOME="/home/registry/registry"
APP_ROOT="$APP_HOME/current"
QUE_USER=registry # or use some other unprivileged system user
QUE_USER=registry # or use some other unprivileged OS user what your registry servers uses
RAILS_ENV=production
RUBY_BUNDLE_PATH=/home/$QUE_USER/.rbenv/shims/bundle
QUE_INSTANCES=1 # or as many really needed based real load
RUBY_BUNDLE=/home/$QUE_USER/.rbenv/shims/bundle
QUE_INSTANCES=1 # or as many really needed based on real load info
### END OF CHANGES
cd $APP_ROOT || exit 1
case ${1-help} in
status)
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE_PATH exec lib/daemons/que_ctl status
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE exec lib/daemons/que_ctl status
;;
start)
echo "$1 que monitor and server"
for i in `seq 1 $QUE_INSTANCES`; do
cd $APP_ROOT && QUE_WORKER_COUNT=1 RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE_PATH exec rake daemon:que:start
echo '.'
cd $APP_ROOT && QUE_WORKER_COUNT=1 RAILS_ENV=$RAILS_ENV QUE_USER=$QUE_USER $RUBY_BUNDLE exec rake daemon:que:start
echo 'que instance started'
done
;;
stop)
echo "$1 que monitor and server"
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE_PATH exec lib/daemons/que_ctl stop
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE exec lib/daemons/que_ctl stop
;;
restart)
echo "$1 que monitor and server"
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE_PATH exec rake daemon:que:restart
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV QUE_USER=$QUE_USER $RUBY_BUNDLE exec rake daemon:que:restart
;;
*)
echo >&2 "Usage: $0 <status|start|stop|restart>"