Commit dd2ba007 authored by Ivo De Decker's avatar Ivo De Decker

daemon: don't start jobs if load too high

Signed-off-by: Ivo De Decker's avatarIvo De Decker <ivodd@debian.org>
parent ec915f2c
......@@ -62,9 +62,26 @@ def init_log
$log.level = Logger::DEBUG
end
def check_load(log,pool)
while true do
load = IO::read('/proc/loadavg').split[1].to_f
sleeptime = 600
# limit in cgi's is typically 20, let's give the importers a higher limit,
# so that web requests are stopped before importers are stopped
if load > 30
log.info "load #{load}, not running next job in pool #{pool}, sleep #{sleeptime}"
sleep(sleeptime)
else
log.debug "load #{load}, running next job in pool #{pool}"
return
end
end
end
def run_bugs_loop
init_log if not defined?($log)
while true do
check_load($log,"bugs")
$log.debug "Running bugs"
now = Time::now
log = `DEBBUGS_CONFIG_FILE=/srv/udd.debian.org/udd/bugs-config perl /srv/udd.debian.org/udd/udd/bugs_gatherer.pl /srv/udd.debian.org/udd/config-ullmann.yaml daemon-run foo 2>&1`
......@@ -148,6 +165,7 @@ def run_daemon
$log.debug "Starting pooler: #{pool}"
imps = Hash[imps]
while true do
check_load($log,pool)
update_status(imps)
never_ran = imps.values.select { |imp| imp['last_time'].nil? }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment