Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py

Issue 2237403002: Add cloudtail start/stop in recipe_modules/goma (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: remove --log-id, sleep 3 seconds Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import argparse
7 import os
8 import signal
9 import subprocess
10 import sys
11 import time
12
13 from slave import goma_utils
14
15
16 def start_cloudtail(args, f):
17 """Write process id of started cloudtail to file object f"""
18
19 proc = subprocess.Popen([args.cloudtail_path,
20 'tail',
21 '--log-id', 'goma_compiler_proxy'
22 '--path',
23 goma_utils.GetLatestGomaCompilerProxyInfo()])
24
25 f.write(str(proc.pid))
26
27
28 def main():
29 parser = argparse.ArgumentParser(
30 description='cloudtail utility for goma recipe module.')
31
32 parser.add_argument('--cloudtail-path',
33 help='path of cloudtail binary')
34 parser.add_argument('--start-cloudtail', action='store_true',
35 help='start cloudtail if this option is enabled')
36 parser.add_argument('--killed-pid',
37 help=('pid that is killed.'
38 ' Do not set this option and'
39 ' --start-cloudtail at the same time'))
40
41 args = parser.parse_args()
42
43 if args.start_cloudtail:
44 # Do not set killed_pid and start_cloudtail at the same time
45 assert args.killed_pid is None
46 start_cloudtail(args, sys.stdout)
47
48 if args.killed_pid is not None:
49 killed_pid = int(args.killed_pid)
50 os.kill(killed_pid, signal.SIGTERM)
51
52 for _ in range(3):
53 time.sleep(1)
54 pid, retcode = os.waitpid(killed_pid, os.WNOHANG)
55 if pid == 0 and retcode == 0:
56 break
57
58 if pid != 0 or retcode != 0:
59 os.kill(killed_pid, os.SIGKILL)
60
61
62
Yoshisato Yanagisawa 2016/08/16 04:16:24 nit one extra space?
tikuta 2016/08/16 05:09:55 Done.
63 if '__main__' == __name__:
64 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698