make WebGUI::Config more reliable with relative paths and chdir. fixes forking upgrade.
This commit is contained in:
parent
bb4c576f66
commit
ffd685c36a
2 changed files with 23 additions and 14 deletions
|
|
@ -16,6 +16,7 @@ package WebGUI::Config;
|
|||
|
||||
use strict;
|
||||
use Class::InsideOut qw(readonly id register);
|
||||
use Cwd ();
|
||||
use base 'Config::JSON';
|
||||
|
||||
my %config = ();
|
||||
|
|
@ -148,14 +149,14 @@ A boolean value that when set to true tells the config system not to store the c
|
|||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $webguiPath = shift;
|
||||
my $webguiPath = Cwd::realpath(shift);
|
||||
my $filename = shift;
|
||||
my $noCache = shift;
|
||||
my $fullPath = $webguiPath.'/etc/'.$filename;
|
||||
if (exists $config{$filename}) {
|
||||
return $config{$filename};
|
||||
} else {
|
||||
my $self = Config::JSON->new($webguiPath."/etc/".$filename);
|
||||
my $self = Config::JSON->new($fullPath);
|
||||
register($self, $class);
|
||||
$webguiRoot{id $self} = $webguiPath;
|
||||
$config{$filename} = $self unless $noCache;
|
||||
|
|
@ -181,9 +182,9 @@ The path to the WebGUI installation.
|
|||
sub readAllConfigs {
|
||||
my $class = shift;
|
||||
my $webguiPath = shift;
|
||||
opendir(DIR,$webguiPath."/etc");
|
||||
my @files = readdir(DIR);
|
||||
closedir(DIR);
|
||||
opendir my $dh, $webguiPath."/etc";
|
||||
my @files = readdir $dh;
|
||||
closedir $dh;
|
||||
my %configs;
|
||||
foreach my $file (@files) {
|
||||
next
|
||||
|
|
@ -191,12 +192,14 @@ sub readAllConfigs {
|
|||
|| $file =~ /^\./
|
||||
|| $file eq 'log.conf'
|
||||
|| $file eq 'spectre.conf';
|
||||
$configs{$file} = eval{WebGUI::Config->new($webguiPath,$file)};
|
||||
eval {
|
||||
$configs{$file} = WebGUI::Config->new($webguiPath,$file)
|
||||
};
|
||||
if ($@) {
|
||||
warn "Config file ".$file." looks to be corrupt or have a syntax error.";
|
||||
}
|
||||
}
|
||||
return \%configs;
|
||||
}
|
||||
return \%configs;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -226,12 +226,18 @@ foreach my $filename (keys %config) {
|
|||
}
|
||||
}
|
||||
if ($upgrade{$upgrade}{pl} ne "") {
|
||||
my $cmd = $perl." ".$upgrade{$upgrade}{pl}." --configFile=".$filename;
|
||||
$cmd .= " --quiet" if ($quiet);
|
||||
if (system($cmd)) {
|
||||
print "\tProcessing upgrade executable failed!\n";
|
||||
fatalError();
|
||||
}
|
||||
my $pid = fork;
|
||||
if (!$pid) {
|
||||
@ARGV = ("--configFile=$filename", $quiet ? ('--quiet') : ());
|
||||
$0 = $upgrade{$upgrade}{pl};
|
||||
do $0;
|
||||
exit;
|
||||
}
|
||||
waitpid $pid, 0;
|
||||
if ($?) {
|
||||
print "\tProcessing upgrade executable failed!\n";
|
||||
fatalError();
|
||||
}
|
||||
}
|
||||
$config{$filename}{version} = $upgrade{$upgrade}{to};
|
||||
$notRun = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue