Skip to content

Commit

Permalink
Ensure that puma workers get their own db connection
Browse files Browse the repository at this point in the history
DB connections are disconnected before puma forks its own worker
processes. This ensures that all puma workers will get new
DB connections.

[#150958544](https://www.pivotaltracker.com/story/show/150958544)

Signed-off-by: Beyhan Veli <[email protected]>
  • Loading branch information
friegger committed Oct 23, 2017
1 parent adfeab6 commit cc379bb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/bosh-director/bin/bosh-director
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ puma_configuration = Puma::Configuration.new do |user_config|
user_config.port config.port
user_config.app rack_app
user_config.preload_app!
# this makes sure that all puma workers get their own db connections
user_config.before_fork { Bosh::Director::Config.db.disconnect }
end
puma_launcher = Puma::Launcher.new(puma_configuration)

Expand Down
1 change: 1 addition & 0 deletions src/bosh-director/lib/bosh/director/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def configure_db(db_config)
if logger
db.logger = logger
db.sql_log_level = :debug
db.log_connection_info = true
end

db
Expand Down

0 comments on commit cc379bb

Please sign in to comment.