Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Solving Mojolicious fork-based multi-processes daemon(eg. hypnotoad) Mojo::mysql connection timeout close issue.
use Mojolicious::Lite;
use Mojo::mysql;
helper db => sub {
state $db = Mojo::mysql->new('mysql://user:pass@/task')->db;
if (! $db->ping ) {
$db->dbh( $db->dbh->clone() ) or die "cannot connect to db";
return $db;
get '/list' => sub {
my $c = shift;
my $rs = $c->db->query('select count(*) as count from list');
my $rs_count = $rs->hash->{count};
$c->render( text => $rs_count );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.