Chromium Code Reviews| OLD | NEW |
|---|---|
| (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)) | |
|
Paweł Hajdan Jr.
2016/08/17 13:57:29
This is a weird structure. Either hardcode sys.std
tikuta
2016/08/18 06:17:03
Done.
| |
| 26 | |
| 27 | |
| 28 def main(): | |
| 29 parser = argparse.ArgumentParser( | |
| 30 description='cloudtail utility for goma recipe module.') | |
| 31 | |
| 32 subparsers = parser.add_subparsers(help='commands for cloudtail') | |
| 33 | |
| 34 parser_start = subparsers.add_parser('start', | |
| 35 help='subcommand to start cloudtail') | |
| 36 parser_start.add_argument('--cloudtail-path', | |
|
Paweł Hajdan Jr.
2016/08/17 13:57:29
Is this a required argument? If so add required=Tr
tikuta
2016/08/18 06:17:03
Done.
| |
| 37 help='path of cloudtail binary') | |
| 38 | |
| 39 parser_stop = subparsers.add_parser('stop', | |
| 40 help='subcommand to stop cloudtail') | |
| 41 parser_stop.add_argument('--killed-pid', type=int, | |
|
Paweł Hajdan Jr.
2016/08/17 13:57:29
Same here.
tikuta
2016/08/18 06:17:03
Done.
| |
| 42 help='pid that is killed.') | |
| 43 | |
| 44 args = parser.parse_args() | |
| 45 | |
| 46 if args.cloudtail_path: | |
|
Paweł Hajdan Jr.
2016/08/17 13:57:29
This is close, but for detecting which command to
tikuta
2016/08/18 06:17:03
Done.
| |
| 47 start_cloudtail(args, sys.stdout) | |
| 48 elif args.killed_pid is not None: | |
| 49 killed_pid = args.killed_pid | |
| 50 # only send SIGKILL signal, let init process do wait for killed_pid | |
|
Paweł Hajdan Jr.
2016/08/17 13:57:29
nit: Start with capital letter, end with a dot.
tikuta
2016/08/18 06:17:03
Done.
| |
| 51 os.kill(killed_pid, os.SIGKILL) | |
| 52 | |
| 53 | |
| 54 if '__main__' == __name__: | |
| 55 sys.exit(main()) | |
| OLD | NEW |