artemave has asked for the wisdom of the Perl Monks concerning the following question:

Greetengs, all.

I'm trying to use configuration directives via Apache2::Module. It works fine until the first module reload (performed by Apache2::Reload). After that it can't read config anymore. Until I restart apache.
Here is the related code:
package dir_browse::dir_browse; use Apache2::Module; ... Apache2::Module::add(__PACKAGE__, [{name => 'START_DIR'}]); ... sub handler : method { my ($self, $r) = @_; ... my $cfg = Apache2::Module::get_config(__PACKAGE__, $r->server, $r->p +er_dir_config) or throw Error; $self->{START_DIR} = $cfg->{ST_DIR}; ... } sub START_DIR { my ($cfg, $parms, $arg1) = @_; $cfg->{ST_DIR} = $arg1; }
And the httpd.conf:
PerlModule Apache2::Reload PerlInitHandler Apache2::Reload ... PerlLoadModule dir_browse::dir_browse <Location /dir_browse> SetHandler perl-script PerlResponseHandler dir_browse::dir_browse PJX_JSDEBUG 2 PJX_DEBUG 1 START_DIR "C:\MP3" </Location>
What am I doing wrong? Or how do I get config reread on each reload?

Thanx,
Artem.

Replies are listed 'Best First'.
Re: Apache2::Module question
by ides (Deacon) on Apr 27, 2007 at 14:26 UTC

    I'm not 100% sure about this, but I always have my configuration modules separate from handler modules. The docs show this in the examples and could be the problem.

    So you'd setup a dir_browse::parameters module that you would PerlLoadModule in and then your existing dir_browse::dir_browse module with the handler as is, except you'd change the __PACKAGE__ in get_config() to 'dir_browse::parameters'. And just PerlModule that one in.

    Hope this helps...

    Frank Wiles <frank@revsys.com>
    www.revsys.com