Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would really recommend looking at another way to implement this. Unless you really need 1 extra thread <em>per instance</em> when you go to production (imagine setting up 3-4 thin / mongrel / etc. servers - each will have the extra thread), there's better ways to go about it.</p> <p>Option 1 - the simplest - is just to create a controller action that will execute your task, and then use wget and cron to trigger that action regularly.</p> <pre><code>20 * * * * /usr/bin/wget --quiet -O - 'http://www.mydomain.com/my_controller/my_action' </code></pre> <p>The problem here is that you've got to deal with authentication / access control - unless you really don't care if some random user can trigger your job (which, frankly, is sometimes the case for very simple jobs).</p> <p>Option 2 - use <a href="https://github.com/tomykaira/clockwork" rel="nofollow">Clockwork</a>/<a href="http://mperham.github.com/sidekiq/" rel="nofollow">Sidekiq</a> or BackgroundRb or some other way of running tasks in the background. I've done this in a production app, and it works very nicely. I chose Clockwork and Sidekiq, and my scheduled tasks look something like this:</p> <p>app/workers/daily_worker.rb:</p> <pre><code>class DailyWorker include Sidekiq::Worker def perform # do stuff here end end </code></pre> <p>clockwork.rb:</p> <pre><code>require 'clockwork' require 'sidekiq' Dir["app/workers/*"].each {|f| load f } module Clockwork every 1.day, 'daily.jobs', :at =&gt; "00:30" do DailyWorker.perform_async end end </code></pre> <p>This to me seemed like the <em>best</em> solution - and it only took me about 15 minutes to get it all up and running.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload