mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-10 01:00:29 +03:00
build: make per-build hard time limit customizable
Add "timeout=n" metadata field that overrides build timeout (in seconds). The default is 7200, i.e. 2 hours.
This commit is contained in:
parent
cc4b57b10b
commit
86f34ee70a
6 changed files with 122 additions and 4 deletions
|
|
@ -913,9 +913,9 @@ def trybuild(app, build, build_dir, output_dir, log_dir, also_check_dir,
|
|||
return True
|
||||
|
||||
|
||||
def force_halt_build():
|
||||
def force_halt_build(timeout):
|
||||
"""Halt the currently running Vagrant VM, to be called from a Timer"""
|
||||
logging.error(_('Force halting build after timeout!'))
|
||||
logging.error(_('Force halting build after {0} sec timeout!').format(timeout))
|
||||
timeout_event.set()
|
||||
vm = vmtools.get_build_vm('builder')
|
||||
vm.halt()
|
||||
|
|
@ -1093,8 +1093,15 @@ def main():
|
|||
if time.time() > endtime:
|
||||
max_build_time_reached = True
|
||||
break
|
||||
if options.server: # enable watchdog timer
|
||||
timer = threading.Timer(7200, force_halt_build)
|
||||
|
||||
# Enable watchdog timer (2 hours by default).
|
||||
if build.timeout is None:
|
||||
timeout = 7200
|
||||
else:
|
||||
timeout = int(build.timeout)
|
||||
if options.server and timeout > 0:
|
||||
logging.debug(_('Setting {0} sec timeout for this build').format(timeout))
|
||||
timer = threading.Timer(timeout, force_halt_build, [timeout])
|
||||
timer.start()
|
||||
else:
|
||||
timer = None
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ def fieldtype(name):
|
|||
build_flags_order = [
|
||||
'disable',
|
||||
'commit',
|
||||
'timeout',
|
||||
'subdir',
|
||||
'submodules',
|
||||
'sudo',
|
||||
|
|
@ -248,6 +249,7 @@ class Build(dict):
|
|||
super().__init__()
|
||||
self.disable = False
|
||||
self.commit = None
|
||||
self.timeout = None
|
||||
self.subdir = None
|
||||
self.submodules = False
|
||||
self.sudo = ''
|
||||
|
|
@ -347,6 +349,7 @@ flagtypes = {
|
|||
'forcevercode': TYPE_BOOL,
|
||||
'novcheck': TYPE_BOOL,
|
||||
'antifeatures': TYPE_LIST,
|
||||
'timeout': TYPE_INT,
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1208,6 +1211,8 @@ def parse_txt_metadata(mf, app):
|
|||
build[pk] = pv
|
||||
elif t == TYPE_BOOL:
|
||||
build[pk] = _decode_bool(pv)
|
||||
elif t == TYPE_INT:
|
||||
build[pk] = int(pv)
|
||||
|
||||
def parse_buildline(lines):
|
||||
v = "".join(lines)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue