diff --git a/lib/Monitorix.pm b/lib/Monitorix.pm index d7a0404..6d15a45 100644 --- a/lib/Monitorix.pm +++ b/lib/Monitorix.pm @@ -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(); diff --git a/monitorix b/monitorix index e661540..5a6b190 100755 --- a/monitorix +++ b/monitorix @@ -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 {