Skip to content

Instantly share code, notes, and snippets.

@SeanRoberts
Created July 7, 2011 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeanRoberts/1070330 to your computer and use it in GitHub Desktop.
Save SeanRoberts/1070330 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment.rb'
require 'daemons'
class DispatchDaemonFetcherDaemon < Daemon::Base
@config = YAML.load_file("#{Rails.root}/config/dispatch_daemon.yml")
@config = @config[Rails.env].to_options
@sleep_time = @config.delete(:sleep_time) || 60
def self.start
puts "Starting DispatchDaemonFetcherDaemon"
# Add your own receiver object below
@fetcher = Fetcher.create({:receiver => DispatchMailer}.merge(@config))
loop do
@fetcher.fetch
sleep(@sleep_time)
end
end
def self.stop
puts "Stopping DispatchDaemonFetcherDaemon"
end
end
DispatchDaemonFetcherDaemon.daemonize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment