Hi All,
I had to go live with a well tested mod_perl system this morning and after enough people got on it started to give internal server errors because a DBI connection couldn't be found anymore. Offline it never did that I guess because it was just me testing it.
I am reading through my mod_perl books right now to try and fix it. For now I changed the code to just connect every time but I need a persistent connection.
Here is what I'm currently using
------------------------------------------------------
use DBI;
use strict;
use vars qw($dbh);
unless (defined($dbh)) {
$dbh = DBI->connect("DBI:mysql:$config->{sqlDatabase}", "$config->{sqlUserName}", "$config->{sqlPass}") or print "Couldn't open database: $DBI::errstr; stopped";
}
------------------------------------------------------
I origionally wrote this system which has about 25 mod_perl files now, in perl with speedy_cgi. A system similary to fast_cgi where it runs each cgi script as a daemon. This is what the speedy_cgi people recommended for a persistent connection. And it seemed to work in mod_perl so I kept it.
It seems like mod_perl is creating multiple processes of the same script and only the origional has a connection.
Can anyone recommend how I can achive a persistent connection that isn't going to fail?
Thanks a lot.
Tony
I had to go live with a well tested mod_perl system this morning and after enough people got on it started to give internal server errors because a DBI connection couldn't be found anymore. Offline it never did that I guess because it was just me testing it.
I am reading through my mod_perl books right now to try and fix it. For now I changed the code to just connect every time but I need a persistent connection.
Here is what I'm currently using
------------------------------------------------------
use DBI;
use strict;
use vars qw($dbh);
unless (defined($dbh)) {
$dbh = DBI->connect("DBI:mysql:$config->{sqlDatabase}", "$config->{sqlUserName}", "$config->{sqlPass}") or print "Couldn't open database: $DBI::errstr; stopped";
}
------------------------------------------------------
I origionally wrote this system which has about 25 mod_perl files now, in perl with speedy_cgi. A system similary to fast_cgi where it runs each cgi script as a daemon. This is what the speedy_cgi people recommended for a persistent connection. And it seemed to work in mod_perl so I kept it.
It seems like mod_perl is creating multiple processes of the same script and only the origional has a connection.
Can anyone recommend how I can achive a persistent connection that isn't going to fail?
Thanks a lot.
Tony