Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: JRuby 0.9.9
-
Fix Version/s: JRuby 1.0.0RC2
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:jdk1.5.08
rails 1.2.3
Description
The following occurs within a rails project:
From within environment.rb, place the following:
MANAGER_PREFS = {
:development => {
:threads => 10,
:root_dir => "/jboss/deploy",
:util_dir => "/usr2/bea/bin"
},
:test => { },
:production => { }
}
if ENV['RAILS_ENV'] != nil
require "lib/manager"
MANAGER=Manager.instance
end
Here's the snippet of Manager which is causing theissue:
- manager
require 'singleton'
require 'socket'
require 'thread'
require 'threadpool'
require 'logger'
require 'tasker' - The manager uses the MANAGER_PREFS variable defined in the
- config/environment.rb
- The manager has two parts:
- + the first periodically checks for servers which
- are managed and checks to see if they are running
- + the second looks in the tasks table for tasks to be
- performed and performs the tasks
class Manager < Thread
include Singleton
def initialize()
@logger = RAILS_DEFAULT_LOGGER
- $DEBUG = true
pool_size = MANAGER_PREFS[ENV['RAILS_ENV'].to_sym][:threads] || 10
@pool = ThreadPool.new(pool_size,@logger)
@continue = true
@tasker = Tasker.instance
super do
cycle = 0
@logger.debug "Manager is sleeping for 60 seconds to give system time to stabilize"
sleep 60 # give time to stabilize
@logger.debug "Manager is now awake"
while @continue do
@logger.debug "Manager doing stuff: #{cycle}" - set true by default
monitor_active = false # fixme
tasker_active = true
begin
settings = GlobalSetting.find_first
@logger.debug "Manager: #{settings.inspect}"
monitor_active = settings.monitor_active
tasker_active = settings.tasker_active
rescue Exception => e
@logger.info "Manager: Exception occurred reading global settings: #{e.message}"
@logger.info "Manager: Exception Backtrace:\n #{e.backtrace.inspect}"
end
check_managed_servers if ((cycle == 0) && (monitor_active))
@logger.debug "Manager stage 1"
perform_tasks if tasker_active
@logger.debug "Manager sleeping"
sleep 10
cycle = (cycle + 1) % 6
end
@logger.debug "Manager Finished"
end
end
end
Here's the stack trace:
/usr2/common/jruby/lib/ruby/1.8/singleton.rb:95:in `new': must be called with a block (ThreadError)
from /usr2/common/jruby/lib/ruby/1.8/singleton.rb:95:in `instance'
from /usr2/common/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `instance'
from ./script/../config/../config/environment.rb:106
from /usr2/common/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from /usr2/common/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from /usr2/common/jruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/webrick.rb:52
from /usr2/common/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from /usr2/common/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from /usr2/common/jruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39
from /usr2/common/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from /usr2/common/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from script/server:2
I ripped out the Singleton code, and it's complaining yet – it seems as though the root cause is that Manager is a child of Thread and while I'm calling super with a block, it's not good enough........
I know that there's differences between MRI and jruby's threading; I'm guessing that I've run into it..... Still, figure y'all would like to know