mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 16:53:37 +02:00
Updated doc init script and que #2724
This commit is contained in:
parent
b18960c32a
commit
f7e639dd0e
6 changed files with 40 additions and 10 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue