Heroku - earthcubeprojects-chords/chords GitHub Wiki

Summary

It took a bit of learning and fiddling to get CHORDS going on heroku. There were a few stumbling blocks:

  • heroku does not look fondly upon development mode. And so production mode is used.
  • A special git push is required to deploy a non-master branch.
  • Rails.configuration.database_configuration[Rails.env]["database"] does not return the name of the actual heroku database.
  • gem 'rails_12factor' had to be added to Gemfile, for asset serving. It doesn't seem to work though.

Eventually I got the site running. But for some reason, assets are not getting served properly, and so the site is useless. It seems to have something to do with the handling of assets in rails production mode. This is strictly a production mode issue, as the same problem shows up if I run on my local machine in production mode.

Bringing up a portal

Heroku CLI

Install the heroku command line tool from the heroku web site. From then on the heroku command will be used.

Steps

  • For some reason, it didn't seem to recognize mysql, so I used the (postgres) pg branch.
  • Trying to get the development version was also difficult, so I let heroku start up the production configuration. Note that 'they' say heroku will ignore our database.yml, and use something of it's own creation.
  • Make sure that gem 'rails_12factor' is in the Gemfile. If you have to add it, do a bundle install, and then check Gemfile and Gemfile.lock into the repository.

Clone and switch to the pg branch:

git clone https://github.com/NCAR/chords_portal.git
cd chords_portal
git checkout pg

Create the heroku app. Note the special git push command, which pushed the local pg branch to a branch named master:

heroku create chords-pg
git push heroku pg:master
heroku run rake db:migrate
heroku run rake db:seed

Shortcut to open the web page:

heroku open

Heroku hints

Command Action
heroku psql You can easily connect to the remote database, using psql.
heroku run bash Open a shell on your remote system.
heroku logs -t Tail the logs on the remote system .
heroku logs -n 500 Look at the last 500 log lines.
heroku open Browse to the website (saves finding and typing the URL)