From 463df1f406720df9a0ca061e05eea935f7440797 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Thu, 16 Jul 2015 18:42:49 +0300 Subject: [PATCH] Que inits script sudo friendly, pid files moved to tmp/pids #2724 --- config/daemons.yml | 4 +++- config/deploy.rb | 11 ++++++++++- doc/que/README.md | 10 ++++++++-- doc/que/que-init-example | 23 ++++++++++------------- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/config/daemons.yml b/config/daemons.yml index 29ce969f4..55e5cdb25 100644 --- a/config/daemons.yml +++ b/config/daemons.yml @@ -1,7 +1,9 @@ dir_mode: script -dir: ../../log +dir: ../../tmp/pids multiple: true backtrace: true monitor: true ontop: false app_name: 'que' +user: <%= ENV['QUE_USER'] || 'registry' %> +group: <%= ENV['QUE_GROUP'] || ENV['QUE_USER'] || 'registry' %> diff --git a/config/deploy.rb b/config/deploy.rb index 05eb64ab4..40a8a5ace 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -138,7 +138,8 @@ set :shared_paths, [ 'public/system', 'export/zonefiles', 'import/bank_statements', - 'import/legal_documents' + 'import/legal_documents', + 'tmp/pids' ] # Optional settings: @@ -180,6 +181,9 @@ task setup: :environment do queue! %(mkdir -p "#{deploy_to}/shared/import/legal_documents") queue! %(chmod g+rx,u+rwx "#{deploy_to}/shared/import/legal_documents") + queue! %(mkdir -p "#{deploy_to}/shared/tmp/pids") + queue! %(chmod g+rx,u+rwx "#{deploy_to}/shared/tmp/pids") + queue! %(touch "#{deploy_to}/shared/config/database.yml") deploy do invoke :'git:clone' @@ -199,6 +203,11 @@ task deploy: :environment do # instance of your project. invoke :'git:clone' invoke :load_commit_hash + + # TEMP until all servers are updated + queue! %(mkdir -p "#{deploy_to}/shared/tmp/pids") + queue! %(chmod g+rx,u+rwx "#{deploy_to}/shared/tmp/pids") + invoke :'deploy:link_shared_paths' invoke :'bundle:install' invoke :'rails:db_migrate' diff --git a/doc/que/README.md b/doc/que/README.md index 3c34a10ac..1dddd8fc3 100644 --- a/doc/que/README.md +++ b/doc/que/README.md @@ -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 diff --git a/doc/que/que-init-example b/doc/que/que-init-example index 9e561d3a8..28e27e957 100644 --- a/doc/que/que-init-example +++ b/doc/que/que-init-example @@ -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 "