[vhffs-dev] [2205] panel now reload configuration file if necessary |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 2205
Author: gradator
Date: 2012-07-15 21:08:47 +0200 (Sun, 15 Jul 2012)
Log Message:
-----------
panel now reload configuration file if necessary
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Conf.pm
trunk/vhffs-api/src/Vhffs.pm
trunk/vhffs-panel/index.pl
trunk/vhffs-public/index.pl
Modified: trunk/vhffs-api/src/Vhffs/Conf.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Conf.pm 2012-07-15 17:15:07 UTC (rev 2204)
+++ trunk/vhffs-api/src/Vhffs/Conf.pm 2012-07-15 19:08:47 UTC (rev 2205)
@@ -98,11 +98,27 @@
}
}
+ $config->{'filename'} = $filename;
+ (undef, undef, undef, undef, undef, undef, undef, undef, undef, $config->{'mtime'}, undef, undef, undef) = stat( $filename );
+
my $self = $config;
bless( $self, $class );
return $self;
}
+=head2 changed
+
+$self->changed;
+
+Return whether configuration file changed on disk (based on mtime).
+
+=cut
+sub changed {
+ my $self = shift;
+ my (undef, undef, undef, undef, undef, undef, undef, undef, undef, $mtime, undef, undef, undef) = stat( $self->{'filename'} );
+ return ($mtime != $self->{'mtime'});
+}
+
=pod
=head1 GET CONFIGURATION BLOCK
=pod
Modified: trunk/vhffs-api/src/Vhffs.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs.pm 2012-07-15 17:15:07 UTC (rev 2204)
+++ trunk/vhffs-api/src/Vhffs.pm 2012-07-15 19:08:47 UTC (rev 2205)
@@ -117,6 +117,21 @@
=pod
+=head1 reload_config
+
+$vhffs->reload_config;
+
+Reload configuration file if necessary.
+
+=cut
+sub reload_config {
+ my $self = shift;
+ return unless $self->{'config'}->changed;
+ $self->{'config'} = new Vhffs::Conf( Vhffs::Constants::CONF_PATH );
+}
+
+=pod
+
=head1 connect
my $dbh = $vhffs->connect;
Modified: trunk/vhffs-panel/index.pl
===================================================================
--- trunk/vhffs-panel/index.pl 2012-07-15 17:15:07 UTC (rev 2204)
+++ trunk/vhffs-panel/index.pl 2012-07-15 19:08:47 UTC (rev 2205)
@@ -54,6 +54,8 @@
# -- requests loop
while (my $cgi = new CGI::Fast) {
+ $vhffs->reload_config;
+
my $panel = new Vhffs::Panel( $vhffs, $cgi );
next unless defined $panel;
Modified: trunk/vhffs-public/index.pl
===================================================================
--- trunk/vhffs-public/index.pl 2012-07-15 17:15:07 UTC (rev 2204)
+++ trunk/vhffs-public/index.pl 2012-07-15 19:08:47 UTC (rev 2205)
@@ -54,6 +54,8 @@
# -- requests loop
while (my $cgi = new CGI::Fast) {
+ $vhffs->reload_config;
+
my $panel = new Vhffs::Panel::Public( $vhffs, $cgi );
next unless defined $panel;