platform/dev: add 'chromite' import & process id handling.
Current devserver does not have 'chromite' dependency. Also, in real devserver,
the cros_update process's id is different from the shell id, and the
path of 'stateful_update' is different from that in drone/shard.
This CL:
1. add 'chromite' import
2. pass the 'devserver directory' to ChromiumOSUpdater.
3. Create a process group before newing the cros_update process. Use the
process group id as the unique file identifier. Kill the whole process group if
neccessary.
BUG=chromium:636467
TEST=local autotest to trigger repair & provision.
real test in devserver chromeos4-devserver2.
pass testCROSAU in dev_integration_test.
Change-Id: Iddf7fcbcaf508b516a8c09bbe7b09fd7209c14a4
Reviewed-on: https://chromium-review.googlesource.com/367741
Commit-Ready: Xixuan Wu <xixuan@chromium.org>
Tested-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/devserver.py b/devserver.py
index 71351ac..39b4dfb 100755
--- a/devserver.py
+++ b/devserver.py
@@ -835,14 +835,15 @@
if full_update:
args = ('%s --full_update' % args)
- p = subprocess.Popen([args], shell=True)
+ p = subprocess.Popen([args], shell=True, preexec_fn=os.setsid)
+ pid = os.getpgid(p.pid)
# Pre-write status in the track_status_file before the first call of
# 'get_au_status' to make sure that the track_status_file exists.
- progress_tracker = cros_update_progress.AUProgress(host_name, p.pid)
+ progress_tracker = cros_update_progress.AUProgress(host_name, pid)
progress_tracker.WriteStatus('CrOS update is just started.')
- return json.dumps((True, p.pid))
+ return json.dumps((True, pid))
else:
cros_update_trigger = cros_update.CrOSUpdateTrigger(
host_name, build_name, updater.static_dir)
@@ -900,7 +901,7 @@
return json.dumps((False, result))
except IOError:
if pid:
- os.kill(int(pid), signal.SIGKILL)
+ os.killpg(int(pid), signal.SIGKILL)
raise
@@ -946,7 +947,7 @@
# filename.
pid = os.path.splitext(os.path.basename(log))[0][len(host_name)+1:]
if cros_update_progress.IsProcessAlive(pid):
- os.kill(int(pid), signal.SIGKILL)
+ os.killpg(int(pid), signal.SIGKILL)
cros_update_progress.DelTrackStatusFile(host_name, pid)