Run Dashing Rails on Heroku - gottfrois/dashing-rails GitHub Wiki

Setting Dashing-rails on Heroku is pretty simple:

  1. Create a new app:

     heroku apps:create example
    
  2. Add RedisToGo addon to heroku's app:

     heroku addons:add redistogo
    
  3. Add PostgresSQL addon to heroku's app (this is up to you):

     heroku addons:add heroku-postgresql:dev
    
  4. Add the following gems to your Gemfile:

     gem 'puma'
     gem 'rails_12factor', group: :production
     gem 'pg',             group: :production
    
  5. Create a new Procfile for you application:

     web: bundle exec puma -p $PORT -e $RACK_ENV -t 0:5
    
  6. Tell Dashing-rails how to use the Heroku's redis connection by setting redis credentials in config/initializers/dashing.rb:

     config.redis_host     = URI.parse(ENV["REDISTOGO_URL"]).host
     config.redis_port     = URI.parse(ENV["REDISTOGO_URL"]).port
     config.redis_password = URI.parse(ENV["REDISTOGO_URL"]).password
    
  7. Create the file config/initializers/database_connection.rb and add the following lines:

     Rails.application.config.after_initialize do
       ActiveRecord::Base.connection_pool.disconnect!
    
       ActiveSupport.on_load(:active_record) do
         config = Rails.application.config.database_configuration[Rails.env]
         config['reaping_frequency'] = ENV['DB_REAP_FREQ'] || 10 # seconds
         config['pool']              = ENV['DB_POOL']      || 5
         ActiveRecord::Base.establish_connection(config)
       end
     end
    
  8. Edit config/environments/production.rb with the following (default js compression cause widget's name issues due to mangling js functions and variables):

     config.assets.js_compressor = Uglifier.new(mangle: false)
    
  9. Locally compile assets using:

     RAILS_ENV=production bundle exec rake assets:precompile
    
  10. Commit and Push to heroku:

     git commit -m "configure dashing to work on heroku"
     git push heroku master
    
  11. That's it! Visit http://your_app.herokuapp.com/dashing/dashboards

You can checkout the following application on Github running on Heroku

puma -t 0:5 lets you configure the number of threads you want puma to run on.