Sha256: c785871ec3d6cc5d4a3a0f5c53b5b4b495c80f98f5d91642d81df17ff6ac3aa7

Contents?: true

Size: 746 Bytes

Versions: 7

Compression:

Stored size: 746 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: couldn't 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

7 entries across 7 versions & 1 rubygems

Version Path
tork-19.4.0 lib/tork/config/rails/worker.rb
tork-19.3.2 lib/tork/config/rails/worker.rb
tork-19.3.1 lib/tork/config/rails/worker.rb
tork-19.3.0 lib/tork/config/rails/worker.rb
tork-19.2.2 lib/tork/config/rails/worker.rb
tork-19.2.1 lib/tork/config/rails/worker.rb
tork-19.2.0 lib/tork/config/rails/worker.rb