diff --git a/runbot/container.py b/runbot/container.py
index d70f66ad..1f61c850 100644
--- a/runbot/container.py
+++ b/runbot/container.py
@@ -168,11 +168,15 @@ def docker_run(run_cmd, log_path, build_dir, container_name, exposed_ports=None,
_logger.info('Started Docker container %s', container_name)
return
-def docker_stop(container_name):
+def docker_stop(container_name, build_dir=None):
"""Stops the container named container_name"""
_logger.info('Stopping container %s', container_name)
- dstop = subprocess.run(['docker', 'stop', container_name])
- # todo delete os.path.join(build_dir, 'end-%s' % container_name)
+ if build_dir:
+ end_file = os.path.join(build_dir, 'end-%s' % container_name)
+ subprocess.run(['touch', end_file])
+ else:
+ _logger.info('Stopping docker without defined build_dir')
+ subprocess.run(['docker', 'stop', container_name])
def docker_is_running(container_name):
dinspect = subprocess.run(['docker', 'container', 'inspect', container_name], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
diff --git a/runbot/models/build.py b/runbot/models/build.py
index 8ec2d245..3c08a4b4 100644
--- a/runbot/models/build.py
+++ b/runbot/models/build.py
@@ -663,8 +663,10 @@ class runbot_build(models.Model):
build._log('_schedule', '%s time exceeded (%ss)' % (build.active_step.name if build.active_step else "?", build.job_time))
build._kill(result='killed')
continue
- elif _docker_state == 'UNKNOWN' and build.active_step._is_docker_step():
- if build.job_time < 60:
+ elif _docker_state == 'UNKNOWN' and (build.local_state == 'running' or build.active_step._is_docker_step()):
+ if build.job_time < 5:
+ continue
+ elif build.job_time < 60:
_logger.debug('container "%s" seems too take a while to start', build._get_docker_name())
continue
else:
@@ -850,7 +852,7 @@ class runbot_build(models.Model):
if build.host != host:
continue
build._log('kill', 'Kill build %s' % build.dest)
- docker_stop(build._get_docker_name())
+ docker_stop(build._get_docker_name(), build._path())
v = {'local_state': 'done', 'requested_action': False, 'active_step': False, 'duplicate_id': False, 'job_end': now()} # what if duplicate? state done?
if not build.build_end:
v['build_end'] = now()
diff --git a/runbot/templates/frontend.xml b/runbot/templates/frontend.xml
index 06d861f1..943a4650 100644
--- a/runbot/templates/frontend.xml
+++ b/runbot/templates/frontend.xml
@@ -135,7 +135,10 @@