-
Notifications
You must be signed in to change notification settings - Fork 8
Deploy and Monitoring
JP Barbosa edited this page Jul 23, 2015
·
4 revisions
nano Gemfile
# Use Postgres as the database for Active Record
gem 'pg'
bundle install
nano config/database.yml
default: &default
adapter: postgresql
pool: 5
timeout: 5000
development:
<<: *default
database: rails_apz_dev
test:
<<: *default
database: rails_apz_test
production:
<<: *default
database: rails_apz_prod
rake db:create
rake db:migrate
rails s
open http://localhost:3000
heroku create
export HOST_NAME_HEROKU=`heroku info -s | grep domain_name | cut -d= -f2`
open https://www.google.com/recaptcha/admin#list
heroku config:set \
HOST_NAME=$HOST_NAME_HEROKU \
SMTP_HOST=$SMTP_HOST \
SMTP_PORT=$SMTP_PORT \
SMTP_USER=$SMTP_USER \
SMTP_PASS=$SMTP_PASS \
RECAPTCHA_PUBLIC_KEY=$RECAPTCHA_PUBLIC_KEY \
RECAPTCHA_PRIVATE_KEY=$RECAPTCHA_PRIVATE_KEY
heroku addons:create heroku-postgresql:hobby-dev
heroku addons:create heroku-redis:hobby-dev
nano Gemfile
# Use Unicorn as the app server
gem 'unicorn'
gem 'rails_12factor'
bundle install
nano Procfile
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
worker: bundle exec sidekiq -q mailers -q default
nano config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 90
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
git add .
git commit -m "Add Heroku config"
git push
git push heroku master
heroku run rake db:migrate
heroku ps:scale worker=1
heroku open
heroku addons:create papertrail
heroku restart
heroku addons:open papertrail