diff --git a/Gemfile b/Gemfile index d01d958..1977fb6 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,9 @@ gem 'sinatra' gem 'sinatra-activerecord' group :production do + gem 'rails_12factor' gem 'pg' + gem 'puma' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index b234b50..626ea64 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -24,9 +24,15 @@ GEM rb-inotify (>= 0.9) minitest (5.8.1) pg (0.18.3) + puma (2.14.0) rack (1.6.4) rack-protection (1.5.3) rack + rails_12factor (0.0.3) + rails_serve_static_assets + rails_stdout_logging + rails_serve_static_assets (0.0.4) + rails_stdout_logging (0.0.4) rb-fsevent (0.9.6) rb-inotify (0.9.5) ffi (>= 0.5.0) @@ -51,6 +57,8 @@ PLATFORMS DEPENDENCIES activerecord pg + puma + rails_12factor rerun sinatra sinatra-activerecord diff --git a/puma.rb b/puma.rb new file mode 100644 index 0000000..afdb99a --- /dev/null +++ b/puma.rb @@ -0,0 +1,15 @@ +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 + # Worker specific setup for Rails 4.1+ + # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot + ActiveRecord::Base.establish_connection +end