lib/ditty/db.rb in ditty-0.4.1 vs lib/ditty/db.rb in ditty-0.6.0
- old
+ new
@@ -3,15 +3,20 @@
require 'sequel'
require 'ditty/services/logger'
require 'active_support'
require 'active_support/core_ext/object/blank'
+pool_timeout = (ENV['DB_POOL_TIMEOUT'] || 5).to_i
+
if defined? DB
Ditty::Services::Logger.instance.warn 'Database connection already set up'
elsif ENV['DATABASE_URL'].blank? == false
# Delete DATABASE_URL from the environment, so it isn't accidently
# passed to subprocesses. DATABASE_URL may contain passwords.
- DB = Sequel.connect(ENV['RACK_ENV'] == 'production' ? ENV.delete('DATABASE_URL') : ENV['DATABASE_URL'])
+ DB = Sequel.connect(
+ ENV['RACK_ENV'] == 'production' ? ENV.delete('DATABASE_URL') : ENV['DATABASE_URL'],
+ pool_timeout: pool_timeout
+ )
DB.sql_log_level = (ENV['SEQUEL_LOGGING_LEVEL'] || :debug).to_sym
DB.loggers << Ditty::Services::Logger.instance
DB.extension(:pagination)