ダン・クァン・ミン Blog

はじめまして

Rails Tutorial - Step by Step

Init project

Create project

$ rails new project-name -d mysql
$ cd project-name
$ bundle install
$ bundle update

Init bitbucket and heroku

$ git init
$ git remote add origin git@bitbucket.org:<username>/<project-name>

$ heroku create
$ heroku apps:rename <new-name>

Config heroku

Gemfile

group :production do
  gem 'puma'
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
end

Puma config

Create Procfile

web: bundle exec puma -C config/puma.rb

Create a configuration file for Puma at config/puma.rb

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
  ActiveRecord::Base.establish_connection
end

Run command

$ heroku config:set MIN_THREADS=1 MAX_THREADS=1

Comments