HACKERS GONNA HACK
How to deploy a tag to Heroku

If you are following the excellent work-flow laid out by Vincent in this post and implemented in his git extension then you will need to know how to deploy a specific tag to Heroku. The syntax for this was not obvious to me and there was little information about it on the interwebs.  So, here it is (run from the master branch):

git push heroku +1.1.1^{commit}:master

What this command does is force (+) push the commit represented by tag 1.1.1 to a remote named heroku.  Share and enjoy.

Running Jobs More Frequently (Than Hourly) on Heroku

Heroku allows you to run cron jobs at most every hour.  However, there are many tasks that need to be run more frequently than that.  Solution?  delayed_job; here’s how…

  # Called by Heroku once per day (for free!)
  task :cron => :environment do
    # Runs this task every five minutes (24*60/5=288) using delayed_job
    1.upto(288) do |run|
      SomeModel.delay(:run_at => (run * 5).minutes.from_now).some_method
    end
  end
Getting PrinceXML Working on Heroku

PrinceXML will work on Heroku; here’s how:

  1. Download the princexml source (generic linux)
  2. Compile princexml and include it in your repo. Use whatever your RAILS_ROOT is as the installation directory when asked; this will create two new directories: bin and lib/prince in RAILS_ROOT
  3. Change the absolute paths in the prince schell script that prince creates in: bin/ to /app/… (this is the value of RAILS_ROOT on Heroku)
  4. Place your license.dat file in the RAILS_ROOT/lib/prince/license directory
  5. Commit your changes
  6. Push to Heroku