Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6875935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:24:56+00:00 2026-05-27T04:24:56+00:00

UPDATED: I used daemon_generator in a Rails 2.3 app to create a daemon. Per

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:24:56+00:00Added an answer on May 27, 2026 at 4:24 am

    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_mail action 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.

    class YourController < ApplicationController
      def create
        do_stuff
        send_email
      end
    
      def send_email
        ExtractedClass.do_stuff(params)
      end
    end
    
    #new class in lib/extracted_class.rb
    class ExtractedClass
      def self.do_stuff(params)
        #put the code that was previously in the send_email
        #function of your controller
      end
    end
    
    #in lib/daemons/mailer.rb
    while($running) do
      ExtractedClass.do_stuff(params)
      sleep 300 # 5 min
    end
    

    This will do several things:

    • You can more easily test the ExtractedClass separately
    • Your daemon is just concerned with how often it should run, and what it should be running. There is no other logic necessary. You now have a thin daemon.
    • You are moving logic out of the controller, also making it thinner (google “skinny controller fat model”)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PHP/MySQL and I've always used DATETIME to store created and updated values,
I've used the webOS Ares tool to create a relatively simple App. It displays
UPDATED I used below solutions (loading Image from stream), but get new problem. img
[Update: I've found the API reference. The method used is below] <?php wp_delete_post( $postid,
My code used to work, but I recently updated jQuery UI to 1.8 and
I've used routing with asp.net 4.0 but one of my hosting companies haven't updated
I thus far used concatenated Id string like 1,2,3 and updated in my table
I have a trigger that is used for auditing inserted, updated and deleted rows.
[Updated below] I am having a problem connecting to a MySQL database using a
Let's say I'm using a frequently used and updated module (such as Connect) with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.