0

I am having issues getting a workling daemon working correctly. When I run:

ruby script/workling_client run

the daemon starts to load rails, but hangs indefintely. When I kill the process, the stack trace is always the same:

/Library/Ruby/Gems/1.8/gems/activesupport-2.1.2/lib/active_support/core_ext/load_error.rb:32:in `new': Interrupt
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:355:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'
from /Library/Ruby/Gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:68
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
 ... 81 levels...
from /Library/Ruby/Gems/1.8/gems/daemons-1.0.10/lib/daemons/cmdline.rb:105:in `call'
from /Library/Ruby/Gems/1.8/gems/daemons-1.0.10/lib/daemons/cmdline.rb:105:in `catch_exceptions'
from /Library/Ruby/Gems/1.8/gems/daemons-1.0.10/lib/daemons.rb:138:in `run'
from script/workling_client:18

If I run the script without the daemons library, it works as expected. I have, in fact, had trouble using the daemon gem to load anything that requires my rails environment. Any ideas?

UPDATE: The workling_client loads worklings listen.rb as a daemon. Instead of loading rails in listen.rb, I changed it so that it gets loaded in workling_client instead, and the process works without a hitch. Therefore, there is some reason that I can't load rails in a daemonized script :-(

robinator
  • 1
  • 2

2 Answers2

1

Can you post the code that starts the daemon script? I know it is possible to load rails in a daemons script since we do it for our delayed_jobs script.

The initial part of the script does:

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config',
      'environment'))

adjust for your environment.rb file in your rails project. Then, the process proceeds to daemonize itself:

Worker::Command.new(ARGV, :workers => worker_config).daemonize

Our script loads rails before doing the daemonize step. If this doesn't work, include how your script loads rails.

christophercotton
  • 5,829
  • 2
  • 34
  • 49
0

Try start working without monitor:

options = {
  :app_name   => "workling",
  :ARGV       => ARGV,
  :dir_mode   => :normal,
  :dir        => File.join(File.dirname(__FILE__), '..', 'log'),
  :log_output => true,
  :multiple   => false,
  :backtrace  => true,
  :monitor    => false
}
LPL
  • 16,827
  • 6
  • 51
  • 95
Misha
  • 11
  • 1