Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequel postgres connection fails when server run as daemon #314

Open
snitko opened this issue Apr 12, 2015 · 4 comments
Open

Sequel postgres connection fails when server run as daemon #314

snitko opened this issue Apr 12, 2015 · 4 comments

Comments

@snitko
Copy link

snitko commented Apr 12, 2015

I've been using Sequel gem (http://sequel.jeremyevans.net/) with postgres adapter inside Goliath and I've noticed a very weird behavior.

If Goliath is run as a daemon, then it fails with Sequel::DatabaseDisconnectError: PG::ConnectionBad: PQconsumeInput() SSL connection has been closed unexpectedly whereas if it is run normally, this never happens.

This error also doesn't happen with sqlite, both in normal and daemonized modes.
Any hints as to why this might be happening?

@snitko
Copy link
Author

snitko commented Apr 13, 2015

Ok, so a good explanation of what's going on is here: thuehlinger/daemons#31

The question then becomes, where should I connect to the DB so that it happens AFTER the process is daemonized? Currently I do it in #initialize. If I connect to the DB in #response the problem goes away, but I don't want to be connecting to the DB upon the first request, it doesn't seem appropriate. I would like the connection to be established before a user hits the site.

@igrigorik
Copy link
Member

You should do it in your config file: https://github.com/postrank-labs/goliath/wiki/Configuration :)

@snitko
Copy link
Author

snitko commented Apr 13, 2015

I have a rather custom setup in my project which has its own config dir and file, I don't want to contaminate the file tree with more files and folders and confuse users. Is there a way I can somehow inject that piece of code next to the #initialize and #response methods? A hook up like #after_initialize in Rails, maybe?

@igrigorik
Copy link
Member

You can pass a custom config via -c directive; check the internal plumbing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants