Skip to content

Commit

Permalink
Disconnect database on boot
Browse files Browse the repository at this point in the history
This is useful when restarting applications on production
  • Loading branch information
jodosha committed Mar 6, 2017
1 parent 2466f3f commit 54cc6b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -12,7 +12,7 @@ gem 'hanami-validations', '~> 1.0.0.beta1', require: false, github: 'hanami/vali
gem 'hanami-router', '~> 1.0.0.beta1', require: false, github: 'hanami/router', branch: '1.0.x'
gem 'hanami-controller', '~> 1.0.0.beta1', require: false, github: 'hanami/controller', branch: '1.0.x'
gem 'hanami-view', '~> 1.0.0.beta1', require: false, github: 'hanami/view', branch: '1.0.x'
gem 'hanami-model', '~> 1.0.0.beta1', require: false, github: 'hanami/model', branch: '1.0.x'
gem 'hanami-model', '~> 1.0.0.beta1', require: false, github: 'hanami/model', branch: 'hanami-model-disconnect'
gem 'hanami-helpers', '~> 1.0.0.beta1', require: false, github: 'hanami/helpers', branch: '1.0.x'
gem 'hanami-mailer', '~> 1.0.0.beta1', require: false, github: 'hanami/mailer', branch: '1.0.x'
gem 'hanami-assets', '~> 1.0.0.beta1', require: false, github: 'hanami/assets', branch: '1.0.x'
Expand Down
4 changes: 4 additions & 0 deletions lib/hanami/components/components.rb
Expand Up @@ -77,6 +77,10 @@ module Components # rubocop:disable Metrics/ModuleLength
register 'model' do
requires 'logger', 'model.configuration', 'model.sql'

prepare do
Hanami::Model.disconnect if Components['model.configuration']
end

resolve do
if Components['model.configuration']
Hanami::Model.load!
Expand Down

0 comments on commit 54cc6b4

Please sign in to comment.