lib/ruby_wolf/server.rb in ruby_wolf-0.3.0 vs lib/ruby_wolf/server.rb in ruby_wolf-0.3.1

- old
+ new

@@ -1,7 +1,5 @@ -require 'logger' - module RubyWolf class Server attr_reader :app, :configs, :socket, :workers def initialize(rack_file, configs) @@ -23,27 +21,29 @@ end private def setup_rack - RubyWolf.log('~~~ Ruby Wolf ~~~') - RubyWolf.log('Loading Rack application') + RubyWolf.logger.info('~~~ Ruby Wolf ~~~') + RubyWolf.logger.info('Loading Rack application') @app, _rack_options = ::Rack::Builder.parse_file(@rack_file) + Rails.logger = RubyWolf.logger if defined?(Rails) + ActiveRecord::Base.logger = RubyWolf.logger if defined?(ActiveRecord) end def setup_socket @socket = TCPServer.new(configs[:host], configs[:port]) - RubyWolf.log("Server is running on #{configs[:host]}:#{configs[:port]}") - RubyWolf.log("Process pid is #{Process.pid}") - RubyWolf.log("Number of worker: #{configs[:worker]}") + RubyWolf.logger.info("Server is running on #{configs[:host]}:#{configs[:port]}") + RubyWolf.logger.info("Process pid is #{Process.pid}") + RubyWolf.logger.info("Number of worker: #{configs[:worker]}") end def handle_loop while stopped_pid = Process.wait do stopped_worker = workers.find { |w| w.pid == stopped_pid } next unless stopped_worker - RubyWolf.log("Worker with pid #{stopped_pid} suddenly stopped", :error) + RubyWolf.logger.info("Worker with pid #{stopped_pid} suddenly stopped", :error) sleep(1) worker = RubyWolf::Worker.new(self) worker.start