I have test app written on ruby, using Sinatra+Sequel.
config.ru:
require './main'
run Sinatra::Application
Example code:
require 'sinatra'
require 'haml'
require 'sequel'
DB=Sequel.connect('oracle://test:test@test')
class Tarification < Sequel::Model(DB[:test_table])
end
get '/' do
haml :index
end
Everything was all right until I started using Phusion Passenger in my test environment. Now I've got exception in nginx error.log:
Sequel::DatabaseError - RuntimeError: The connection cannot be reused in the forked process.
Is the right thing to place DB connection routine to rackup file config.ru or it's better to do it in a different way? If the first variant than how to make call to the connection correct from application code?
P.S.: I know that I can do passenger_spawn_method conservative
and continue opening connection in app code, but it's not the way I'm looking for because of it's speed and resource usage issues.