Skip to content

Commit

Permalink
Add app.json for Heroku deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
jarydkrish committed Jun 21, 2020
1 parent c1fffb1 commit 3dd8d70
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ gem 'jbuilder', '~> 2.7'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 4.1'
gem 'redis', '~> 4.0'
gem 'resque'
gem 'rollbar'
gem 'sass-rails', '>= 6'
gem 'turbolinks', '~> 5'
gem 'webpacker', github: 'rails/webpacker'
Expand Down
25 changes: 25 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ GEM
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.1)
mono_logger (1.1.0)
msgpack (1.3.3)
multi_json (1.14.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.2)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
Expand All @@ -171,6 +175,8 @@ GEM
puma (4.3.5)
nio4r (~> 2.0)
rack (2.2.3)
rack-protection (2.0.8.1)
rack
rack-proxy (0.6.5)
rack
rack-test (1.1.0)
Expand All @@ -186,10 +192,19 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
redis (4.2.1)
redis-namespace (1.6.0)
redis (>= 3.0.4)
regexp_parser (1.7.1)
resque (2.0.0)
mono_logger (~> 1.0)
multi_json (~> 1.0)
redis-namespace (~> 1.6)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
reverse_markdown (2.0.0)
nokogiri
rexml (3.2.4)
rollbar (2.22.1)
rubocop (0.85.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
Expand All @@ -208,6 +223,7 @@ GEM
ruby-progressbar (1.10.1)
ruby-vips (2.0.17)
ffi (~> 1.9)
ruby2_keywords (0.0.2)
rubyzip (2.3.0)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
Expand All @@ -223,6 +239,11 @@ GEM
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
semantic_range (2.3.0)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.8.1)
tilt (~> 2.0)
solargraph (0.39.8)
backport (~> 1.1)
benchmark
Expand Down Expand Up @@ -257,6 +278,8 @@ GEM
tzinfo (1.2.7)
thread_safe (~> 0.1)
unicode-display_width (1.7.0)
vegas (0.1.11)
rack (>= 1.0.0)
webdrivers (4.4.1)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
Expand Down Expand Up @@ -285,6 +308,8 @@ DEPENDENCIES
puma (~> 4.1)
rails!
redis (~> 4.0)
resque
rollbar
rubocop
rubocop-rails
sass-rails (>= 6)
Expand Down
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: bundle exec puma -C config/puma.rb
worker: QUEUE=* bundle exec rake resque:work
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ Minitest tests can be found in the [test](./test) directory.

## Initial Deployment

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/HarvestProfit/marketingplan)
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/HarvestProfit/just-an-entries-example)
16 changes: 16 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Entry Demonstration",
"description": "Simple entry app for testing out some stuff.",
"repository": "https://github.com/HarvestProfit/just-an-entries-example",
"logo": "https://www.harvestprofit.com/apple-touch-icon.png",
"keywords": ["rails"],
"buildpacks": [
{ "url": "heroku/nodejs" },
{ "url": "heroku/ruby" }
],
"addons": [
"heroku-postgresql:hobby-dev",
"heroku-redis:hobby-dev",
"rollbar:free"
]
}
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
# config.cache_store = :mem_cache_store

# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "just_an_entries_example_production"

config.action_mailer.perform_caching = false
Expand Down
28 changes: 28 additions & 0 deletions config/initializers/resque.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'resque/failure/multiple'
require 'resque/failure/redis'
require 'rollbar'
require 'redis'

if ENV['REDIS_URL']
Resque.redis = Redis.new(url: ENV['REDIS_URL'])
else
Resque.inline = true
end

if Rails.env.development?
Resque.logger = Logger.new(STDOUT)
Resque.logger.level = Logger::INFO
else
Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Rollbar]
Resque::Failure.backend = Resque::Failure::Multiple
end

Resque.before_fork do
defined?(ActiveRecord::Base) &&
ActiveRecord::Base.connection.disconnect!
end

Resque.after_fork do
defined?(ActiveRecord::Base) &&
ActiveRecord::Base.establish_connection
end
74 changes: 74 additions & 0 deletions config/initializers/rollbar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Rollbar.configure do |config|
# Without configuration, Rollbar is enabled in all environments.
# To disable in specific environments, set config.enabled=false.

config.access_token = ENV['ROLLBAR_ACCESS_TOKEN']

# Here we'll disable in 'test':
config.enabled = false if Rails.env.test? || Rails.env.development?
config.send_extra_frame_data = :app

# By default, Rollbar will try to call the `current_user` controller method
# to fetch the logged-in user object, and then call that object's `id`
# method to fetch this property. To customize:
# config.person_method = 'my_current_user'
# config.person_id_method = 'my_id'

# Additionally, you may specify the following:
# config.person_username_method = 'username'
# config.person_email_method = 'email'

# If you want to attach custom data to all exception and message reports,
# provide a lambda like the following. It should return a hash.
# config.custom_data_method = lambda { {:some_key => 'some_value' } }

# Add exception class names to the exception_level_filters hash to
# change the level that exception is reported at. Note that if an exception
# has already been reported and logged the level will need to be changed
# via the rollbar interface.
# Valid levels: 'critical', 'error', 'warning', 'info', 'debug', 'ignore'
# 'ignore' will cause the exception to not be reported at all.
# config.exception_level_filters.merge!('MyCriticalException' => 'critical')
#
# You can also specify a callable, which will be called with the exception instance.
# config.exception_level_filters.merge!('MyCriticalException' => lambda { |e| 'critical' })
config.exception_level_filters.merge!(
'Rack::Timeout::RequestTimeoutException' => 'ignore',
'ActionController::RoutingError' => 'ignore'
)

# Enable asynchronous reporting (uses girl_friday or Threading if girl_friday
# is not installed)
# config.use_async = true
# Supply your own async handler:
# config.async_handler = Proc.new { |payload|
# Thread.new { Rollbar.process_from_async_handler(payload) }
# }

# Enable asynchronous reporting (using sucker_punch)
# config.use_sucker_punch

# Enable delayed reporting (using Sidekiq)
# config.use_sidekiq
# You can supply custom Sidekiq options:
# config.use_sidekiq 'queue' => 'default'

# If your application runs behind a proxy server, you can set proxy parameters here.
# If https_proxy is set in your environment, that will be used. Settings here have precedence.
# The :host key is mandatory and must include the URL scheme (e.g. 'http://'), all other fields
# are optional.
#
# config.proxy = {
# host: 'http://some.proxy.server',
# port: 80,
# user: 'username_if_auth_required',
# password: 'password_if_auth_required'
# }

# If you run your staging application instance in production environment then
# you'll want to override the environment reported by `Rails.env` with an
# environment variable like this: `ROLLBAR_ENV=staging`. This is a recommended
# setup for Heroku. See:
# https://devcenter.heroku.com/articles/deploying-to-a-custom-rails-environment
config.environment = ENV['ROLLBAR_ENV'].presence || Rails.env
end

0 comments on commit 3dd8d70

Please sign in to comment.