Crash on running Sinatra on Heroku

I have been trying to get Sinatra running on Heroku, although it was working fine on my localhost, but when getting to Heroku. A few things need to pay attention to.

Here a checklist, if you have been getting the some crashes.

  • Do you have config.ru and Gemfile set properly?

Because Heroku is used as rack, so you need define how to run it. To run on localhost, the command is 

$rackup config.ru

Just take note that you will be running on port 9292.

Aside that, you also need to have Gemfile set up properly. Here is  the documentation https://devcenter.heroku.com/articles/rack
 
  • Are you running HAML?

I was getting issue when I started adding in HAML. I later narrowed down that the config.ru, I need to modular app, if not by running Sinatra::Application will cause the crash. So how to change it to modular app? You can check out the documentation here http://www.sinatrarb.com/intro#Sinatra::Base%20-%20Middleware,%20Libraries,%20and%20Modular%20Apps. After that you need to change the config.ru to run your Sinatra modular app e.g.: run SkeletonApp 

or you can also refer to a template on github https://github.com/abachman/heroku-sinatra-skeleton/blob/master/application.rb for more info.

 

runSkeletonApp