Skip to content

Commit

Permalink
Allow puma_workers configuration
Browse files Browse the repository at this point in the history
Now you are able to change the number of puma workers.
This also changes the max_connections when using postgres.
  • Loading branch information
HParker committed Sep 8, 2017
1 parent a0a7271 commit 636b24e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/gemstash/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class Configuration
fetch_timeout: 20,
# Actual default for db_connection_options is dynamic based on the adapter
db_connection_options: {},
puma_threads: 16
puma_threads: 16,
puma_workers: 1
}.freeze

DEFAULT_FILE = File.expand_path("~/.gemstash/config.yml").freeze
Expand Down Expand Up @@ -59,7 +60,7 @@ def database_connection_config
when "sqlite3"
{ max_connections: 1 }.merge(self[:db_connection_options])
when "postgres", "mysql", "mysql2"
{ max_connections: self[:puma_threads] + 1 }.merge(self[:db_connection_options])
{ max_connections: (self[:puma_workers] * self[:puma_threads]) + 1 }.merge(self[:db_connection_options])
else
raise "Unsupported DB adapter: '#{self[:db_adapter]}'"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/gemstash/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

threads 0, Gemstash::Env.current.config[:puma_threads].to_i
bind Gemstash::Env.current.config[:bind].to_s
workers 1
workers Gemstash::Env.current.config[:puma_workers].to_i
rackup Gemstash::Env.current.rackup

0 comments on commit 636b24e

Please sign in to comment.