title: Heroku, cron, delayed_job and workers (Rails 3)
body: <p>I have two questions:</p>
  
  <ol>
  <li>How can I add a heroku worker just before running a delayed job and remove it after it finishes?</li>
  <li>Is my cron.rake ok?</li>
  </ol>
  
  <p>cron.rake:</p>
  
  <pre><code>desc "This task is called by the Heroku cron add-on"
  task :cron =&gt; :environment do
  
    puts "requesting homepage to refresh cache"
    uri = URI.parse('http://something.com')
    Net::HTTP.get(uri)
    puts "end requesting homepage"
  
    puts "start sending daily mail"
    User.notified_today.each do |user|
      Delayed::Job.enqueue UserMailer.daily_mail(user).deliver
    end
    puts "end sending daily mail"
  
  end
  </code></pre>
  
  <p>I use <a href="https://github.com/collectiveidea/delayed_job" rel="nofollow">collectiveidea delayed_job</a>.</p>