mirror of https://github.com/mikaku/Monitorix.git
make sure that HTTPd logfile is created on startup and on every SIGHUP
This commit is contained in:
parent
6b4eac6cb3
commit
4bbba328ac
|
@ -77,6 +77,11 @@ sub httpd_setup {
|
|||
return; # parent returns
|
||||
}
|
||||
|
||||
# create the HTTPd logfile
|
||||
open(OUT, "> " . $config->{httpd_builtin}->{log_file});
|
||||
close(OUT);
|
||||
chown($uid, $gid, $config->{httpd_builtin}->{log_file});
|
||||
|
||||
setgid($gid);
|
||||
setuid($uid);
|
||||
setsid();
|
||||
|
|
|
@ -74,6 +74,9 @@ sub HUP_handler {
|
|||
my ($signal) = @_;
|
||||
my $myself = (caller(0))[3];
|
||||
|
||||
my (undef, undef, $uid) = getpwnam($config{httpd_builtin}->{user});
|
||||
my (undef, undef, $gid) = getgrnam($config{httpd_builtin}->{group});
|
||||
|
||||
logger("SIG$signal caught.");
|
||||
|
||||
# upon receiving a SIGHUP signal the logfile is re-opened
|
||||
|
@ -82,6 +85,11 @@ sub HUP_handler {
|
|||
open(STDOUT, ">> $config{log_file}") || logger("Can't write to LOG: $!");
|
||||
open(STDERR, ">> $config{log_file}") || logger("Can't write to LOG: $!");
|
||||
logger("$myself: reopening log file.");
|
||||
|
||||
# create the HTTPd logfile
|
||||
open(OUT, "> " . $config{httpd_builtin}->{log_file});
|
||||
close(OUT);
|
||||
chown($uid, $gid, $config{httpd_builtin}->{log_file});
|
||||
}
|
||||
|
||||
sub ALRM_handler {
|
||||
|
|
Loading…
Reference in New Issue