Last active
May 29, 2016 17:03
-
-
Save MyklClason/71477f35a1494bc87fcd07cee9d39de0 to your computer and use it in GitHub Desktop.
A trivial Rails cron job made using the Que gem
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
# app/jobs/cron_job.rb | |
class CronJob < Que::Job | |
# To minimize log clutter from unavailable jobs, | |
# @run_at should be a bit less than Que.wake_interval | |
@run_at = proc { 59.seconds.from_now } | |
def run | |
# Do stuff here | |
CronJob.enqueue | |
end | |
end |
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
# config/initializers/que.rb | |
Que.mode = :async | |
Que.wake_interval = 60.seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment