Skip to content

Commit cd8a94e

Browse files
committed
update puma config
1 parent 6034158 commit cd8a94e

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

config/deploy.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# set :shared_dirs, fetch(:shared_dirs, []).push('config')
2929
# set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/secrets.yml')
3030
set :shared_dirs, fetch(:shared_dirs, []).push('tmp/sockets', 'tmp/pids')
31-
set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'Gemfile.lock')
31+
set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'Gemfile.lock', 'config/puma.rb')
3232

3333
# This task is the environment that is loaded all remote run commands, such as
3434
# `mina deploy` or `mina rake`.
@@ -123,6 +123,12 @@
123123
end
124124
end
125125

126+
task :my_start_puma do
127+
in_path(fetch(:current_path)) do
128+
comment %{Starting puma...}
129+
command %{}
130+
end
131+
end
126132
# For help in making your deploy script, see the Mina documentation:
127133
#
128134
# - https://github.com/mina-deploy/mina/docs

config/puma.rb

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,26 @@
44
# the maximum value specified for Puma. Default is set to 5 threads for minimum
55
# and maximum, this matches the default thread size of Active Record.
66
#
7+
root = File.expand_path("../..", __FILE__)
8+
79
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
810
threads threads_count, threads_count
911

1012
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
1113
#
1214
port ENV.fetch("PORT") { 3000 }
1315

16+
# Set up socket location
17+
bind "unix://#{root}/tmp/sockets/puma.sock"
18+
19+
# Logging
20+
# stdout_redirect "#{root}/log/puma.stdout.log", "#{root}/log/puma.stderr.log", true
21+
22+
# Set master PID and state locations
23+
pidfile "#{root}/tmp/pids/puma.pid"
24+
state_path "#{root}/tmp/pids/puma.state"
25+
activate_control_app
26+
1427
# Specifies the `environment` that Puma will run in.
1528
#
1629
environment ENV.fetch("RAILS_ENV") { "development" }
@@ -21,7 +34,7 @@
2134
# Workers do not work on JRuby or Windows (both of which do not support
2235
# processes).
2336
#
24-
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
37+
workers ENV.fetch("WEB_CONCURRENCY") { 5 }
2538

2639
# Use the `preload_app!` method when specifying a `workers` number.
2740
# This directive tells Puma to first boot the application and load code
@@ -38,10 +51,10 @@
3851
# option you will want to use this block to reconnect to any threads
3952
# or connections that may have been created at application boot, Ruby
4053
# cannot share connections between processes.
41-
#
42-
# on_worker_boot do
43-
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
44-
# end
54+
55+
on_worker_boot do
56+
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
57+
end
4558

4659
# Allow puma to be restarted by `rails restart` command.
4760
plugin :tmp_restart

0 commit comments

Comments
 (0)