From af8206ef5b06f24036fac700e3dc7cd12e44a44e Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Tue, 8 Mar 2016 19:57:25 -0500 Subject: [PATCH] Added puma --- Gemfile | 3 +++ Gemfile.lock | 2 ++ config/puma.rb | 29 +++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 config/puma.rb diff --git a/Gemfile b/Gemfile index 7a99b38..dcdb74b 100644 --- a/Gemfile +++ b/Gemfile @@ -45,3 +45,6 @@ group :development do gem 'spring' end +group :production do + gem 'puma' +end diff --git a/Gemfile.lock b/Gemfile.lock index 86e9d5a..1986059 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,6 +74,7 @@ GEM multi_json (1.11.2) nokogiri (1.6.7.2) mini_portile2 (~> 2.0.0.rc2) + puma (3.1.0) rack (1.6.4) rack-test (0.6.3) rack (>= 1.0) @@ -151,6 +152,7 @@ DEPENDENCIES coffee-rails (~> 4.1.0) jbuilder (~> 2.0) jquery-rails + puma rails (= 4.2.5.1) sass-rails (~> 5.0) sdoc (~> 0.4.0) diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 0000000..eedb466 --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,29 @@ +# Change to match your CPU core count +workers 1 + +# Min and Max threads per worker +threads 1, 6 + +app_dir = File.expand_path("../..", __FILE__) +shared_dir = "#{app_dir}/shared" + +# Default to production +rails_env = ENV['RAILS_ENV'] || "production" +environment rails_env + +# Set up socket location +bind "unix://#{shared_dir}/sockets/puma.sock" + +# Logging +stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true + +# Set master PID and state locations +pidfile "#{shared_dir}/pids/puma.pid" +state_path "#{shared_dir}/pids/puma.state" +activate_control_app + +on_worker_boot do + require "active_record" + ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished + ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/database.yml")[rails_env]) +end