[#164] Workers should restart periodically

They restart once a day, if the worker completes a job at least every hour.
The worker ID is compared to the hour of day and if the modulus matches, then
it exits (and is restarted by MCE). Should do the trick with memory usage.
This commit is contained in:
Oliver Gorwits
2014-11-14 00:11:09 +00:00
parent 016d090d26
commit ebb5adc6ee
2 changed files with 8 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
* [#161] Updated IOS-XR SSHCollector * [#161] Updated IOS-XR SSHCollector
* [#165] Mention system clock in docs * [#165] Mention system clock in docs
* [#164] Workers should restart periodically
[BUG FIXES] [BUG FIXES]

View File

@@ -38,6 +38,13 @@ sub worker_body {
}; };
$self->close_job($job); $self->close_job($job);
# restart worker once a day.
# relies on the worker seeing a job at least every hour.
my $hour = [localtime()]->[2];
if ($wid and (($wid % 24) == $hour)) {
$self->exit(0, "recycling worker $wid");
}
} }
} }