Module: JRuby::Rack::Worker

Defined in:
lib/jruby/rack/worker.rb,
lib/jruby/rack/worker/env.rb,
lib/jruby/rack/worker/logger.rb,
lib/jruby/rack/worker/version.rb

Constant Summary collapse

JAR_PATH =
File.expand_path("../../jruby-rack-worker_#{VERSION}.jar", File.dirname(__FILE__))
ENV =
Hash.new do |hash, key|
  if hash.key? key = key.to_s
    hash[key]
  else
    manager = self.manager
    val = manager ? manager.getParameter(key) : nil
    val = ::ENV[key] if val.nil?
    hash[key] = val
  end
end
VERSION =
'0.10.0'
@@logger =
nil

Class Method Summary collapse

Class Method Details

.load_jar(method = :load) ⇒ Object



9
10
11
# File 'lib/jruby/rack/worker.rb', line 9

def self.load_jar(method = :load)
  send(method, JAR_PATH) # load JAR_PATH
end

.log_error(e, logger = nil) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/jruby/rack/worker/logger.rb', line 5

def self.log_error(e, logger = nil)
  return unless ( logger ||= self.logger )
  
  message = "\n#{e.class} (#{e.message}):\n"
  message << '  ' << e.backtrace.join("\n  ")
  logger.error("#{message}\n\n")
end

.loggerObject



14
15
16
17
18
19
20
21
22
# File 'lib/jruby/rack/worker/logger.rb', line 14

def self.logger
  @@logger ||= begin
    if defined?(Rails.logger)
      Rails.logger
    else
      default_logger
    end
  end
end

.logger=(logger) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/jruby/rack/worker/logger.rb', line 24

def self.logger=(logger)
  if @@logger == false
    require 'logger'
    @@logger = Logger.new(nil)
  else
    @@logger = logger
  end
end

.logger?Boolean



33
# File 'lib/jruby/rack/worker/logger.rb', line 33

def self.logger?; !!@@logger; end

.managerObject



16
# File 'lib/jruby/rack/worker/env.rb', line 16

def self.manager; $worker_manager; end