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

Side by Side 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 unified diff | Download patch
OLDNEW
(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())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698