Created
July 7, 2011 19:26
-
-
Save SeanRoberts/1070330 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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