Created
April 13, 2010 15:17
-
-
Save mikehale/364717 to your computer and use it in GitHub Desktop.
Lightweight delayed job (for use by cron)
This file contains hidden or 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
| module Jobs | |
| class HelloWorld < Struct.new(:text) | |
| def perform | |
| Rails.logger.debug text | |
| Rails.logger.debug "sleeping for 7 seconds" | |
| sleep(7) | |
| end | |
| end | |
| end | |
| __END__ | |
| require 'rubygems' | |
| require 'active_record' | |
| require 'yaml' | |
| require 'delayed_job' | |
| Delayed::Worker.backend = :active_record | |
| dbconfig = YAML::load(File.open('config/database.yml'))["development"] | |
| ActiveRecord::Base.establish_connection(dbconfig) | |
| $LOAD_PATH << "app/models" | |
| require 'jobs/failure_notified_perform' | |
| Dir["app/models/jobs/*"].each do |job| | |
| require job | |
| end | |
| Delayed::Job.enqueue(Jobs::HelloWorld.new("Hi Adam!")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment