lib/arsenicum/main.rb in arsenicum-0.2.1.1 vs lib/arsenicum/main.rb in arsenicum-0.3.0
- old
+ new
@@ -1,7 +1,9 @@
module Arsenicum
class Main
+ attr_reader :queues
+
def run(config)
$0 = 'arsenicum[main]'
if config.daemon
Process.daemon true, true
@@ -16,12 +18,16 @@
configure_io config
configure_log config
before_boot(config)
- threads = config.queue_configurations.map{|qc|qc.build.start_async}
+ @queues = config.queue_configurations.map{|qc|qc.build}
+ threads = @queues.map(&:start_async)
begin
+ sleep 10
+ trap_signal
+
threads.each(&:join)
rescue Interrupt
end
end
@@ -40,9 +46,16 @@
def before_boot(config);end
def configure_log(config)
Arsenicum::Logger.configure config.logger_config
+ end
+
+ def trap_signal
+ [:TERM, :INT,].each do |sig|
+ queues.each(&:stop)
+ exit 1
+ end
end
autoload :RailsMain, 'arsenicum/main/rails_main'
end
end