title: Rake Task timing out on Heroku - Move Rake task to worker using Sidekiq
body: <p>I recently realized that my rake tasks can time out on Heroku, and I happen to have...a lot of them.</p>
  
  <p>Here is an example of my rake task:</p>
  
  <pre><code>namespace :test do
  
    desc "Test Rake Task"
    task get_list: :environment do
      require 'net/ftp'
      sftp = Net::SFTP.start('ftp.test.com','luigi', :password =&gt; 'pass_word')
      records = sftp.download!("luigi/list.xml")
      records_hash = Hash.from_xml(records)
      records_hash['Report']['Details'].each do |record|
        contact = Contact.create(              
            first_name: record['FirstName'],
            last_name: record['LastName'],
            date_of_birth: record['DateofBirth']
        )
        if contact.valid?
          puts "Created contact"
        else
          puts "Invalid contact"
        end
      end    
    end
  end
  </code></pre>
  
  <p>I <strong><em>think</em></strong> that I need to move this to a background worker. It could take 5+ minutes to loop through this task and add each contact to the database. I would like to use <code>Sidekiq</code>, but I've never used "workers" or set this up before.</p>
  
  <p>In general, how would I go about setting <code>Sidekiq</code> up to run on Heroku, and then move the above task to a background worker? I would like for this "worker" or "task" to be scheduled once a week, Monday mornings at 8 am.</p>
  
  <p>My app settings:</p>
  
  <pre><code>Procfile:
  
  web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
  </code></pre>
  
  <p>I am using a postgres Database, Rails 4.0.0, ruby 2.0.0, and as I mentioned earlier my app is hosted on Heroku.</p>