[Catalyst] auto re-load of application yaml config file?

Jonathan Rockway jon at jrock.us
Wed Jul 23 02:23:56 BST 2008


* On Tue, Jul 22 2008, Marc Sebastian Pelzer wrote:
> Hello,
>
> I'm running a Catalyst application under mod_perl and wonder if there
> is a Plugin available that detects changes on the main  application
> .yml config file and does a automatic re-load if needed?  It not -
> what would be the most elegant (and less I/O intensive) way  of doing
> this? Would it be enough to do a
>
> __PACKAGE__->config( 'Plugin::ConfigLoader' => { file =>
> my_config.yml' } );
> in my Root controller when I detect a change? Also, is there a way to
> store the state (maybe the mtime of the config file) in memory without
> being lost between requests? Or do I need to store the mtime in a
> database/memcache/tempfile (which would be "expensive")?
> Many thanks in advance for any hint :)

Reading the config file causes a lot of things to happen (instantiating
your controllers with certain arguments, for example), so this won't
work.  You really need to just restart the app from scratch when you
change the config.

If you want lightweight on-the-fly configurability, you should roll your
own.  You will have to engineer something with a compromise that meets
your needs.  For example, checking the database every time you read a
variable will mean the config settings update quickly, but you also slow
your app way down.  YMMV and all that ;)

Regards,
Jonathan Rockway

-- 
print just => another => perl => hacker => if $,=$"



More information about the Catalyst mailing list