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..384edb58829a18906306a176ecbc67c46b69c441 |
--- /dev/null |
+++ b/scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py |
@@ -0,0 +1,49 @@ |
+#!/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 |
+ |
+from common import goma_utils |
ukai
2016/08/15 06:54:00
goma_utils in common? it is in slave?
tikuta
2016/08/16 02:16:56
Done.
|
+ |
+ |
+def start_cloudtail(args, f): |
+ """Write process id of started cloudtail to file object f""" |
+ |
+ proc = subprocess.Popen([args.cloudtail_path, |
+ 'tail', |
+ '--log-id', args.log_id, |
+ '--path', goma_utils.GetLatestGomaCompilerProxyInfo()], |
Yoshisato Yanagisawa
2016/08/15 07:19:30
I want to know the design choice why --log-id is p
tikuta
2016/08/16 02:16:56
Thank you for comment.
But I'm not sure why JSON i
Yoshisato Yanagisawa
2016/08/16 02:50:10
As we talked offline,
it should be better for clou
tikuta
2016/08/16 02:56:21
Done.
|
+ ) |
+ |
+ f.write(str(proc.pid)) |
+ |
+ |
+def main(): |
+ parser = argparse.ArgumentParser(description='cloudtail utility for goma recipe module.') |
ukai
2016/08/15 06:54:00
long line?
tikuta
2016/08/16 02:16:56
Done.
|
+ |
+ parser.add_argument('--cloudtail-path', |
+ help='path of cloudtail binary') |
+ parser.add_argument('--log-id', |
Yoshisato Yanagisawa
2016/08/16 02:50:10
i.e. I suggest to remove this command line argumen
tikuta
2016/08/16 02:56:21
Done.
|
+ help='id of log') |
+ parser.add_argument('--start-cloudtail', action='store_true', |
+ help='start cloudtail if this option is enabled') |
+ parser.add_argument('--killed-pid', |
+ help='pid that is killed') |
Yoshisato Yanagisawa
2016/08/15 07:19:30
Is it allowed to set both start-cloudtail and kill
tikuta
2016/08/16 02:16:56
I wrote assertion and added a message to help.
|
+ |
+ args = parser.parse_args() |
+ |
+ if args.start_cloudtail: |
+ start_cloudtail(args, sys.stdout) |
+ |
+ if args.killed_pid is not None: |
+ os.kill(int(args.killed_pid), signal.SIGTERM) |
Yoshisato Yanagisawa
2016/08/15 07:19:30
Don't you wait the program termination?
(also SIGK
tikuta
2016/08/16 02:16:56
Done.
|
+ |
+ |
+if '__main__' == __name__: |
+ sys.exit(main()) |