Skip to content

Instantly share code, notes, and snippets.

@andrewzimmer906
Created October 4, 2012 16:37
Show Gist options
  • Save andrewzimmer906/3834824 to your computer and use it in GitHub Desktop.
Save andrewzimmer906/3834824 to your computer and use it in GitHub Desktop.
Daemons
#!/usr/bin/env ruby
# You might want to change this
ENV["RAILS_ENV"] ||= "daemon"
require File.dirname(__FILE__) + "/../../config/application"
#require 'rubygems'
Rails.application.require_environment!
$running = true
Signal.trap("TERM") do
$running = false
end
while($running) do
account = Account.find(1)
#Rails.logger.info "account = #{account}"
# Replace this with your code
Rails.logger.auto_flushing = true
Rails.logger.info "This daemon is still running at #{Time.now}.\n"
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment