Merge branch 'master' of github.com:domify/registry

This commit is contained in:
Martin Lensment 2015-07-14 13:52:06 +03:00
commit 5eee6c8065
6 changed files with 40 additions and 10 deletions

View file

@ -1,4 +1,9 @@
14.07.2015
* Updated que init script doc example, now status and stop works faster
07.07.2015
* Before applyling 20150707104937_refactor_reserved_domains.rb migration, enable hstore extension in db
01.07.2015

View file

@ -13,7 +13,7 @@ gem 'iso8601', '~> 0.8.2' # for dates and times
gem 'hashie-forbidden_attributes', '~> 0.1.1'
# load env
gem 'figaro', '~> 1.1.0'
gem 'figaro', '~> 1.1.1'
# model related
gem 'pg', '~> 0.18.0'

View file

@ -567,7 +567,7 @@ DEPENDENCIES
epp-xml (~> 1.0.3)
fabrication (~> 2.13.2)
faker (~> 1.4.3)
figaro (~> 1.1.0)
figaro (~> 1.1.1)
grape (~> 0.12.0)
guard (~> 2.12.6)
guard-rails (~> 0.7.1)

View file

@ -27,7 +27,7 @@ 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
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV lib/daemons/que_ctl status
;;
start)
echo "$1 que monitor and server"
@ -38,7 +38,7 @@ start)
;;
stop)
echo "$1 que monitor and server"
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE_PATH exec rake daemon:que:stop
cd $APP_ROOT && RAILS_ENV=$RAILS_ENV lib/daemons/que_ctl stop
;;
restart)
echo "$1 que monitor and server"

View file

@ -8,11 +8,36 @@ Dir.chdir(root)
require File.join(root, "config", "environment")
@running = true
Signal.trap("TERM") do
@running = false
# from que gem rake task
if defined?(::Rails) && Rails.respond_to?(:application)
# ActiveSupport's dependency autoloading isn't threadsafe, and Que uses
# multiple threads, which means that eager loading is necessary. Rails
# explicitly prevents eager loading when the environment task is invoked,
# so we need to manually eager load the app here.
Rails.application.eager_load!
end
# rubocop: disable Style/WhileUntilDo
while @running do
Que.logger.level = Logger.const_get((ENV['QUE_LOG_LEVEL'] || 'INFO').upcase)
Que.worker_count = 1
Que.wake_interval = (ENV['QUE_WAKE_INTERVAL'] || 0.1).to_f
Que.mode = :async
# When changing how signals are caught, be sure to test the behavior with
# the rake task in tasks/safe_shutdown.rb.
stop = false
%w( INT TERM ).each do |signal|
trap(signal) {stop = true}
end
at_exit do
$stdout.puts "Finishing Que's current jobs before exiting..."
Que.worker_count = 0
Que.mode = :off
$stdout.puts "Que's jobs finished, exiting..."
end
loop do
sleep 0.01
break if stop
end

View file

@ -3,4 +3,4 @@ require 'rubygems'
require 'daemons/rails/config'
config = Daemons::Rails::Config.for_controller(File.expand_path(__FILE__))
Daemons::Rails.run config[:script], config.to_hash
Daemons::Rails.run config[:script], config.to_hash