Hello everyone,

  I`m writing a module to process templates on which our web server is
  built.  This  module  is  invoked  during PerlInitHandler. We have a
  global  configuration  for  our  site  which  is  a  plain text file
  containing a hash like this:
  {
             bgcolor => '',
             text => '',
  }
  etc...
  
  This  configuration  can  be  changed  using a simple web page or by
  uploading  it  directly  using  FTP.  Since my module processes each
  request  it  does  $cfg  =  do '/path/to/config'. Doing this on each
  request  can  be  time consuming -- i want to load the configuration
  again  after the modification time of the configuration has changed.
  After  reading the guide i have found a snippet of code which i have
  inserting  in the handler function of my module. So the module looks
  like this now:

  [...]
  use vars qw ($VERSION %MODIFIED);
  [...]
  *My::Apache::Module::handler = \&ApacheRequestInit;
  sub ApacheRequestInit {
      [...]
      my $file = '/path/to/config';
      $^M  =  (stat  $file)[9];  #  even  if  not set -- does not work
                                 #  correctyly
      if (!$MODIFIED{$file} and $MODIFIED{$file} != -M $file) {
         unless ($auth_config = do $file) {
            if ( $@ ) {
               $r->log_error( "Unable to load configuration." );
               return SERVER_ERROR;
            }
         }
         $r->log_error( "Configuration reloaded..." );
         $MODIFIED{$file} = -M $file;
         $r->log_error("Modification time: " . $MODIFIED{$file});
      }
      [...]
  }

  I  have  restarted the server on which i test all the code and began
  to  watch  ErrorLog  to  see  if it works. On each request my module
  reloads  the  configuration  again,  but  the  modification  was not
  changed. Going to /perl-status i check the MODIFIED hash and see the
  path  to the configuration with the modification value and even so i
  think it is because i set my module to handle all request comming to
  the   root  location  /.  What  shall  i  do  properly  handle  the
  modification time of a file in my module?

  Any help will be great. Thanks in advance.
  
Best regards,
Alexei V. Alexandrov ([EMAIL PROTECTED])



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to