Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/loops
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ begin
rescue SystemExit => e
Kernel.exit(e.status)

rescue Exception => e
rescue => e
STDERR.puts("Unhandled exception: #{e.message} (#{e.class})")
STDERR.puts(e.backtrace.join("\n"))
Kernel.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion lib/loops/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def sleep_with_shutdown_support(seconds)
@pm.start_shutdown!
return false

rescue Exception => e
rescue => e
debug("Sleep terminated with exception: #{e.class.to_s}")
return false
end
Expand Down
26 changes: 4 additions & 22 deletions lib/loops/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def #{meth_name}(message)
def load_loop_class(name, config)
loop_name = config['loop_name'] || name

klass_files = [Loops.loops_root + "#{loop_name}_loop.rb", "#{loop_name}_loop"]
klass_files = [File.join(Loops.loops_root, "#{loop_name}_loop.rb"), "#{loop_name}_loop"]
begin
klass_file = klass_files.shift
debug "Loading class file: #{klass_file}"
Expand All @@ -126,7 +126,7 @@ def load_loop_class(name, config)

begin
klass.check_dependencies
rescue Exception => e
rescue => e
error "Loop #{name} dependencies check failed: #{e} at #{e.backtrace.first}"
return false
end
Expand All @@ -144,7 +144,7 @@ def start_loop(name, klass, config)
klass.initialize_loop(config)
debug "Initialization successful"
end
rescue Exception => e
rescue => e
error("Initialization failed: #{e.message}\n " + e.backtrace.join("\n "))
return
end
Expand Down Expand Up @@ -178,7 +178,6 @@ def start_loop(name, klass, config)
the_loop = klass.new(worker, name, config)

debug "Starting the loop #{name}!"
fix_ar_after_fork
# reseed the random number generator in case Loops calls
# srand or rand prior to forking
srand
Expand All @@ -204,7 +203,7 @@ def create_logger(loop_name, config)
return Loops.default_logger if config['logger'] == 'default'
Loops::Logger.new(config['logger'])

rescue Exception => e
rescue => e
message = "Can't create a logger for the #{loop_name} loop! Will log to the default logger!"
puts "ERROR: #{message}"

Expand All @@ -227,21 +226,4 @@ def setup_signals
trap('INT', stop)
trap('EXIT', stop)
end

def fix_ar_after_fork
if Object.const_defined?('ActiveRecord')
if ActiveRecord::VERSION::MAJOR < 3
ActiveRecord::Base.allow_concurrency = true
elsif Object.const_defined?('Rails')
Rails.application.config.allow_concurrency = true
end

ActiveRecord::Base.clear_all_connections!
if ActiveRecord::VERSION::MAJOR >= 4
ActiveRecord::Base.connection_pool.connections.map(&:verify!)
else
ActiveRecord::Base.verify_active_connections!
end
end
end
end
4 changes: 2 additions & 2 deletions lib/loops/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ def run
if config['max_requests'] && @total_served >= config['max_requests'].to_i
disconnect_client_and_exit
end
rescue Exception => e
rescue => e
error "Exception from process message! We won't be ACKing the message."
error "Details: #{e} at #{e.backtrace.first}"
disconnect_client_and_exit
end
end

@client.join
rescue Exception => e
rescue => e
error "Closing queue connection because of exception: #{e} at #{e.backtrace.first}"
disconnect_client_and_exit
end
Expand Down
4 changes: 2 additions & 2 deletions lib/loops/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def run
@worker_block.call(self)
normal_exit = true
exit(0)
rescue Exception => e
rescue => e
message = SystemExit === e ? "exit(#{e.status})" : e.to_s
if SystemExit === e and e.success?
if normal_exit
Expand All @@ -61,7 +61,7 @@ def run
else
raise ArgumentError, "Invalid engine name: #{@engine}"
end
rescue Exception => e
rescue => e
logger.error("Exception from worker: #{e} at #{e.backtrace.first}")
end

Expand Down