Run Dashing Rails on Heroku - gottfrois/dashing-rails GitHub Wiki
Setting Dashing-rails on Heroku is pretty simple:
-
Create a new app:
heroku apps:create example
-
Add RedisToGo addon to heroku's app:
heroku addons:add redistogo
-
Add PostgresSQL addon to heroku's app (this is up to you):
heroku addons:add heroku-postgresql:dev
-
Add the following gems to your
Gemfile
:gem 'puma' gem 'rails_12factor', group: :production gem 'pg', group: :production
-
Create a new
Procfile
for you application:web: bundle exec puma -p $PORT -e $RACK_ENV -t 0:5
-
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
-
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
-
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)
-
Locally compile assets using:
RAILS_ENV=production bundle exec rake assets:precompile
-
Commit and Push to heroku:
git commit -m "configure dashing to work on heroku" git push heroku master
-
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.