I suspect you are instantiating your database handle directly on startup and a single connection gets inherited by every single worker process, which doesn't work.
You need a connection manager that is fork aware like DBIx::Connector or make handle instantiation lazy.
Here's a little example.
package Mojolicious::Plugin::Database;
use Mojo::Base 'Mojolicious::Plugin';
use DBI;
has dbh => sub { DBI->connect(...) };
...
sub register {
my ($self, $app) = @_;
...
$app->helper(database => sub { $self->dbh });
...
}
...
P.S.: Can somebody please write a general purpose plugin for this so i never have to explain it again? :)
--
Sebastian Riedel
http://mojolicio.us
http://twitter.com/kraih
http://blog.kraih.com
> --
> You received this message because you are subscribed to the Google Groups "Mojolicious" group.
> To post to this group, send email to mojol...@googlegroups.com.
> To unsubscribe from this group, send email to mojolicious...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mojolicious?hl=en.
>
:)
Gave me a chuckle... this same problem was common 13 years ago when
mod_perl was first getting popular.
Not a plugin, but I wrote this a while ago for the same reason:
http://toroid.org/ams/etc/mojolicious-db-handles
-- ams
https://github.com/kraih/mojo/wiki/Hypnotoad-prefork-web-server
topic of Database connection problem in preforking
I wrote some days ago.
2011/3/14 Łukasz Lewandowski <lukasz.metys...@gmail.com>:
--
Ben van Staveren
phone: +62 81 70777529
email: benvans...@gmail.com