Restart HTTP built-in on every SIGHUP

Now the HTTP built-in will be restart every time Monitorix received the
SIGHUP signal. This should also fix thos annoying sporadic hangups of the
HTTP server, and also a truncation in the recent rotated logfile.
This commit is contained in:
Jordi Sanfeliu 2018-10-17 11:54:05 +02:00
parent d81c5282de
commit d4d76d775d
2 changed files with 15 additions and 5 deletions

View File

@ -17,6 +17,9 @@
setup the owner, group and permission bits to that directory every time
Monitorix is started.
(thanks to Sander Bos for pointing this out)
- Added to restart the HTTP built-in every time Monitorix receives the SIGHUP
signal. This should also fix sporadic hangups in the HTTP and a truncation in
the rotated logfile.
- Fixed a bad memory scaling in *BSD systems.
- Fixed in 'process.pm' to fully honour the option 'netstats_in_bps'.
- Fixed to force Monitorix to be started at the end of boot in systemd-based

View File

@ -72,6 +72,8 @@ sub HUP_handler {
my ($signal) = @_;
my $myself = (caller(0))[3];
return if $options{n}; # only continue if it's a daemon
my (undef, undef, $uid) = getpwnam($config{httpd_builtin}->{user});
my (undef, undef, $gid) = getgrnam($config{httpd_builtin}->{group});
@ -85,11 +87,16 @@ sub HUP_handler {
chmod(0600, $config{log_file});
logger("$myself: opening a new log file.");
# create the HTTPd logfile
open(OUT, "> " . $config{httpd_builtin}->{log_file});
close(OUT);
chown($uid, $gid, $config{httpd_builtin}->{log_file});
chmod(0600, $config{httpd_builtin}->{log_file});
# restart HTTP built-in
if(lc($config{httpd_builtin}->{enabled}) eq "y") {
if(defined($config{httpd_pid})) {
require HTTPServer;
kill(15, $config{httpd_pid});
kill(9, $config{httpd_pid});
httpd_setup(\%config, $options{d});
logger("Restarted built-in HTTP server (pid $config{httpd_pid}).") if (defined($config{httpd_pid}));
}
}
}
sub daemonize {