Skip to content

Instantly share code, notes, and snippets.

@denniskuczynski
Created March 14, 2012 22:43
Show Gist options
  • Save denniskuczynski/2040147 to your computer and use it in GitHub Desktop.
Save denniskuczynski/2040147 to your computer and use it in GitHub Desktop.
Basic Stalker Example
# lib/jobs/stalker_example.rb with Full Rails Environment -- This should be stripped down to the bare essentials needed to run...
require File.expand_path("../../../config/environment", __FILE__)
module Stalker
PROCESSING_DELAY = 5
job "basic_job" do |args|
log "Running (basic_job), Args: #{args.inspect}"
Stalker.enqueue("second_job", { :id => args["id"] }, { :delay => PROCESSING_DELAY })
log "Enqueued (second-job) with delay of #{PROCESSING_DELAY} seconds"
end
job "second_job" do |args|
log "Running (second_job), Args: #{args.inspect}"
log "Test Finished"
end
error do |exception|
log "Exception running job #{exception.inspect}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment