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

Unified 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: do _stop_cloudtail anyway 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 side-by-side diff with in-line comments
Download patch
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..1ad08aa7b4bfd470e5433645b648532448d86a69
--- /dev/null
+++ b/scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py
@@ -0,0 +1,56 @@
+#!/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 slave import goma_utils
+
+
+def start_cloudtail(args):
+ """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()])
+
+ sys.stdout.write(str(proc.pid))
+
+
+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.set_defaults(command='start')
+ parser_start.add_argument('--cloudtail-path', required=True,
+ help='path of cloudtail binary')
+
+ parser_stop = subparsers.add_parser('stop',
+ help='subcommand to stop cloudtail')
+ parser_stop.set_defaults(command='stop')
+ parser_stop.add_argument('--killed-pid', type=int, required=True,
+ help='pid that is killed.')
+
+ args = parser.parse_args()
+
+ if args.command == 'start':
+ start_cloudtail(args)
+ elif args.command == 'stop':
+ killed_pid = args.killed_pid
+ # 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.
+ 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.
+
+
+if '__main__' == __name__:
+ sys.exit(main())

Powered by Google App Engine
This is Rietveld 408576698