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 | |
| 12 from slave import goma_utils | |
| 13 | |
| 14 | |
| 15 def start_cloudtail(args): | |
| 16 """Write process id of started cloudtail to file object f""" | |
| 17 | |
| 18 proc = subprocess.Popen([args.cloudtail_path, | |
| 19 'tail', | |
| 20 '--log-id', 'goma_compiler_proxy' | |
| 21 '--path', | |
| 22 goma_utils.GetLatestGomaCompilerProxyInfo()]) | |
| 23 | |
| 24 sys.stdout.write(str(proc.pid)) | |
| 25 | |
| 26 | |
| 27 def main(): | |
| 28 parser = argparse.ArgumentParser( | |
| 29 description='cloudtail utility for goma recipe module.') | |
| 30 | |
| 31 subparsers = parser.add_subparsers(help='commands for cloudtail') | |
| 32 | |
| 33 parser_start = subparsers.add_parser('start', | |
| 34 help='subcommand to start cloudtail') | |
| 35 parser_start.set_defaults(command='start') | |
| 36 parser_start.add_argument('--cloudtail-path', required=True, | |
| 37 help='path of cloudtail binary') | |
| 38 | |
| 39 parser_stop = subparsers.add_parser('stop', | |
| 40 help='subcommand to stop cloudtail') | |
| 41 parser_stop.set_defaults(command='stop') | |
| 42 parser_stop.add_argument('--killed-pid', type=int, required=True, | |
| 43 help='pid that is killed.') | |
| 44 | |
| 45 args = parser.parse_args() | |
| 46 | |
| 47 if args.command == 'start': | |
| 48 start_cloudtail(args) | |
| 49 elif args.command == 'stop': | |
| 50 killed_pid = args.killed_pid | |
| 51 # Only send SIGKILL signal, let init process do wait for killed_pid. | |
|
Paweł Hajdan Jr.
2016/08/19 09:39:04
nit: Is this comment really useful?
tikuta
2016/08/19 09:53:12
Done.
| |
| 52 os.kill(killed_pid, signal.SIGKILL) | |
|
Paweł Hajdan Jr.
2016/08/19 09:39:04
nit: Just use args.killed_pid here, no need for te
tikuta
2016/08/19 09:53:12
Done.
| |
| 53 | |
| 54 | |
| 55 if '__main__' == __name__: | |
| 56 sys.exit(main()) | |
| OLD | NEW |