[Catalyst] Catalyst I18N::DBI prevent connect at startup

2013-06-06 Thread Stefan
Hi!

 

I'm using Catalyst with the Catalyst::Plugin::I18N::DBI module.

 

The catalyst page is served through apache2 with mod_perl.

 

When starting apache2, the I18N module tries to connect immediately to the
MySQL server.

 

Here comes the problem:

At boot, apache2 tries to start before MySQL. Since MySQL is not yet
running, the I18N module fails with the following error (of course because
no MySQL):

DBI connect('database:localhost:3306','User',...) failed: Can't connect to
local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at
/usr/local/share/perl/5.10.1/Catalyst/Plugin/I18N/DBI.pm line 196.

 

This prevents apache2 to start correctly thus I have to start it always
manually after each boot which works fine because now mysql is running.

 

Is there a possibility to prevent this early connection or force a lazy
connection?

 

Thanks

Stefan

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


AW: [Catalyst] Catalyst I18N::DBI prevent connect at startup

2013-06-06 Thread Stefan
 Which OS/distribution do you use? If a Linux, do you have upstart jobs or
a SystemV-init-system?

Actually it's Ubuntu 10.04.4. Apache is started by SystemV-Init system
whereas mysql is an upstart script.
As far as I know there is no simple solution to define the dependency that
apache (or any sysvinit script) should start after mysql (any upstart
script).
If both would be of the same type, this would be fairly easy.
Additional discussion on this topic can be found here:
http://serverfault.com/questions/513526/force-apache-start-after-mysql
As you can see in the solution posted on Serverfault, it's not quite
optimal.

Thus I thought that it would be better to tell Catalyst or I18N somehow to
wait for the first Client-Request and THEN connect to mysql, instead of
connecting at startup.

---
Stefan


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/