UPDATED: I used daemon_generator in a Rails 2.3 app to create a daemon. Per Jeff Perrin’s suggestions below i created the following configuration. I updated this question with the final solution for others that are struggling to get a daemon working.
For debugging purposes I cut my lib/pulse_check_email.rb file down to this:
class PulseCheckEmail
def self.send_pulse_check_mail
# removed all conditional statements and other "stuff" to debug
end
end
My lib/daemons/mailer.rb file:
require File.dirname(__FILE__) + "/../../config/environment"
require 'pulse_check_email'
while($running) do
PulseCheckEmail.send_pulse_check_mail
sleep 300 # 5 min
end
Thanks for your help!
Regardless of whether you can call a controller method from a daemon in your Rails application, this is not something I would recommend. I would suggest that you extract the code that is currently in the
send_mailaction of the controller into a separate class (that could be put in the /lib directory as well). Then you can call that code from both your daemon and your controller.This will do several things: