Sha256: 747f137d2bd6be26aa97f20c799d01b40c72628abafc5605bd10cce9ac58fb67

Contents?: true

Size: 747 Bytes

Versions: 13

Compression:

Stored size: 747 Bytes

Contents

# although inherited as a file descriptor during the fork(), the database
# connection cannot be shared between the master and its workers or amongst
# the workers themselves because access to the file descriptor isn't mutexed
if defined? ActiveRecord::Base
  base = ActiveRecord::Base

  info =
    if base.respond_to? :connection_info        # rails >= 3.1.0
      base.connection_info
    elsif base.respond_to? :connection_pool     # rails >= 2.2.1
      base.connection_pool.spec.config
    else
      warn "#{$0}: config/rails/worker: could not read connection information"
      {}
    end

  # in-memory databases are private to each process so they're safely fork()ed
  base.connection.reconnect! unless info[:database] == ':memory:'
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
tork-20.0.1 lib/tork/config/rails/worker.rb
tork-20.0.0 lib/tork/config/rails/worker.rb
tork-19.11.1 lib/tork/config/rails/worker.rb
tork-19.10.0 lib/tork/config/rails/worker.rb
tork-19.9.0 lib/tork/config/rails/worker.rb
tork-19.8.2 lib/tork/config/rails/worker.rb
tork-19.8.1 lib/tork/config/rails/worker.rb
tork-19.8.0 lib/tork/config/rails/worker.rb
tork-19.7.0 lib/tork/config/rails/worker.rb
tork-19.6.1 lib/tork/config/rails/worker.rb
tork-19.6.0 lib/tork/config/rails/worker.rb
tork-19.5.1 lib/tork/config/rails/worker.rb
tork-19.5.0 lib/tork/config/rails/worker.rb