Is there any way to debug a daemon in Ruby Mine. The way I am calling this file is like this
Daemons.run(file, options)
where file is the name of file and options is the bunch of options that I am passing to the file.
Is there any way to debug a daemon in Ruby Mine. The way I am calling this file is like this
Daemons.run(file, options)
where file is the name of file and options is the bunch of options that I am passing to the file.
I'm also trying to debug a Rails daemon (gem daemons). The ActiveMessaging poller script in particular. However the ruby-debug-ide fails to attach due to various reasons (race conditions, etc).
The solution I came up with is to use gem rails-daemons. This works with ActiveMessaging and allows to me to create all kinds of daemons, and importantly, be able to debug them in RubyMine
Workaround
Use https://github.com/mirasrael/daemons-rails to create a new daemon. This works with RubyMine 6.3.3, Rails 4, Ruby 2.1.2 on OSX 10.8.x
Sample Daemon
#!/usr/bin/env ruby
# You might want to change this
ENV["RAILS_ENV"] ||= "development"
root = File.expand_path(File.dirname(__FILE__))
root = File.dirname(root) until File.exists?(File.join(root, 'config'))
Dir.chdir(root)
require File.join(root, "config", "environment")
$running = true
Signal.trap("TERM") do
$running = false
end
while($running) do
# Replace this with your code
Rails.logger.auto_flushing = true
Rails.logger.info "This daemon is still running at #{Time.now}.\n"
# ADDED MY CODE BELOW HERE TO START ActiveMessaging
Rails.logger = Logger.new(STDOUT)
ActiveMessaging.logger = Rails.logger
# Load ActiveMessaging
ActiveMessaging::load_processors
# Start it up!
ActiveMessaging::start
sleep 10
end