[dancer-users] Dancer calling database connection

David Precious davidp at preshweb.co.uk
Thu Sep 24 15:51:38 BST 2015


On Mon, 21 Sep 2015 08:43:09 +0000 (UTC)
Mike Cu <mike_cu80 at yahoo.com> wrote:

> the Dancer advent calendar says that:  Use Starman's --preload-app
> option to enable this (but be aware that this can cause Bad Things to
> happen if resources like database connections or other sockets are
> opened by your app at compile time, as they will be unintentionally
> shared amongst child processes. what is actually meant by that? when
> a url is requested my route is calling the model which opens a
> database connection, does sql and closes the connection. 
> 
> So this is done at runtime. when would calling database connection at
> compile time then ?also calling connect_cached would cause any
> problems under a preforked server like starman? 

Belatedly - I would only expect you to see any issues if you grab a
database connection in a BEGIN block or similar.  If you're using
Dancer::Plugin::Database, though, you don't need to worry as it's
designed to be fork and thread-safe for you.

Either way, connections established at run-time should be fine even if
you use Starman's --preload-app option.



More information about the dancer-users mailing list