Index: scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py |
diff --git a/scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py b/scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ff1d36eba631026fc64d5c1c4cafce41e89a24ca |
--- /dev/null |
+++ b/scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py |
@@ -0,0 +1,55 @@ |
+#!/usr/bin/env python |
+# Copyright (c) 2016 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+import argparse |
+import os |
+import signal |
+import subprocess |
+import sys |
+import time |
+ |
+from slave import goma_utils |
+ |
+ |
+def start_cloudtail(args, f): |
+ """Write process id of started cloudtail to file object f""" |
+ |
+ proc = subprocess.Popen([args.cloudtail_path, |
+ 'tail', |
+ '--log-id', 'goma_compiler_proxy' |
+ '--path', |
+ goma_utils.GetLatestGomaCompilerProxyInfo()]) |
+ |
+ 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.
|
+ |
+ |
+def main(): |
+ parser = argparse.ArgumentParser( |
+ description='cloudtail utility for goma recipe module.') |
+ |
+ subparsers = parser.add_subparsers(help='commands for cloudtail') |
+ |
+ parser_start = subparsers.add_parser('start', |
+ help='subcommand to start cloudtail') |
+ 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.
|
+ help='path of cloudtail binary') |
+ |
+ parser_stop = subparsers.add_parser('stop', |
+ help='subcommand to stop cloudtail') |
+ 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.
|
+ help='pid that is killed.') |
+ |
+ args = parser.parse_args() |
+ |
+ 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.
|
+ start_cloudtail(args, sys.stdout) |
+ elif args.killed_pid is not None: |
+ killed_pid = args.killed_pid |
+ # 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.
|
+ os.kill(killed_pid, os.SIGKILL) |
+ |
+ |
+if '__main__' == __name__: |
+ sys.exit(main()) |