From 8d9de083c35c3e65f438895aa57e1fa73016d123 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Sun, 20 May 2018 18:03:54 +0100 Subject: Fix incorrect debug message on statedb removal --- lorrycontroller/statedb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lorrycontroller/statedb.py b/lorrycontroller/statedb.py index 17b31dd..b2bac7e 100644 --- a/lorrycontroller/statedb.py +++ b/lorrycontroller/statedb.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2017 Codethink Limited +# Copyright (C) 2014-2018 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -645,7 +645,7 @@ class StateDB(object): yield row[0], row[1], row[2] def remove_job(self, job_id): - logging.debug('StateDB.append_to_job_output(%r,..) called', job_id) + logging.debug('StateDB.remove_job(%r,..) called', job_id) assert self.in_transaction c = self.get_cursor() c.execute('DELETE FROM jobs WHERE job_id = ?', (job_id,)) -- cgit v1.2.1 From cf9d17ce9da862e1b70f83bab70c432f190fcea6 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Fri, 10 May 2019 12:05:01 +0100 Subject: Ensure child processes of subprocesses are killed with the parent Assign a session ID to subprocesses, making it the group leader of any child processes, so that we may clean them up with the parent. --- lorry-controller-minion | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lorry-controller-minion b/lorry-controller-minion index 72f1a39..9eb6657 100755 --- a/lorry-controller-minion +++ b/lorry-controller-minion @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2019 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,6 +24,7 @@ import os import platform import random import select +import signal import subprocess import tempfile import time @@ -171,7 +172,8 @@ class MINION(cliapp.Application): argv, stdin=devnull, stdout=pipe[1], - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, + preexec_fn=os.setsid) os.close(pipe[1]) devnull.close() @@ -212,7 +214,8 @@ class MINION(cliapp.Application): return stdout, stderr, exit def kill_job(self): - self.process.kill() + pgid = os.getpgid(self.process.pid) + os.killpg(pgid, signal.SIGKILL) return self.process.wait() def update_webapp_about_job(self, job_spec, stdout, stderr, exit): -- cgit v1.2.1