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

Side by Side Diff: scripts/slave/recipe_modules/goma/api.py

Issue 2375843005: Stop redirect stdout/stderr and remove close_fds=True (Closed)
Patch Set: use file for pid Created 4 years, 2 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
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/goma/example.expected/linux.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from contextlib import contextmanager 5 from contextlib import contextmanager
6 6
7 from recipe_engine import recipe_api 7 from recipe_engine import recipe_api
8 8
9 class GomaApi(recipe_api.RecipeApi): 9 class GomaApi(recipe_api.RecipeApi):
10 """GomaApi contains helper functions for using goma.""" 10 """GomaApi contains helper functions for using goma."""
11 11
12 def __init__(self, **kwargs): 12 def __init__(self, **kwargs):
13 super(GomaApi, self).__init__(**kwargs) 13 super(GomaApi, self).__init__(**kwargs)
14 self._goma_dir = None 14 self._goma_dir = None
15 self._goma_started = False 15 self._goma_started = False
16 16
17 self._goma_ctl_env = {} 17 self._goma_ctl_env = {}
18 self._cloudtail_pid = None 18 self._cloudtail_pid = None
ukai 2016/09/29 07:55:01 remove? hold self.m.path['tmp_base'].join('cloudt
tikuta 2016/09/29 08:00:50 Done.
19 self._goma_jobs = None 19 self._goma_jobs = None
20 20
21 @property 21 @property
22 def service_account_json_path(self): 22 def service_account_json_path(self):
23 if self.m.platform.is_win: 23 if self.m.platform.is_win:
24 return 'C:\\creds\\service_accounts\\service-account-goma-client.json' 24 return 'C:\\creds\\service_accounts\\service-account-goma-client.json'
25 return '/creds/service_accounts/service-account-goma-client.json' 25 return '/creds/service_accounts/service-account-goma-client.json'
26 26
27 @property 27 @property
28 def cloudtail_path(self): 28 def cloudtail_path(self):
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 def build_data_dir(self): 126 def build_data_dir(self):
127 return self.m.properties.get('build_data_dir') 127 return self.m.properties.get('build_data_dir')
128 128
129 def _start_cloudtail(self): 129 def _start_cloudtail(self):
130 """Start cloudtail to upload compiler_proxy.INFO 130 """Start cloudtail to upload compiler_proxy.INFO
131 131
132 Raises: 132 Raises:
133 InfraFailure if it fails to start cloudtail 133 InfraFailure if it fails to start cloudtail
134 """ 134 """
135 135
136 assert self._cloudtail_pid is None
137
138 step_result = self.m.python( 136 step_result = self.m.python(
139 name='start cloudtail', 137 name='start cloudtail',
140 script=self.resource('cloudtail_utils.py'), 138 script=self.resource('cloudtail_utils.py'),
141 args=['start', 139 args=['start',
142 '--cloudtail-path', self.cloudtail_path], 140 '--cloudtail-path', self.cloudtail_path,
141 '--pid-file', self.m.raw_io.output(
142 leak_to=self.m.path['tmp_base'].join('pid.txt'))],
ukai 2016/09/29 07:55:01 cloudtail.pid?
tikuta 2016/09/29 08:00:50 Done.
143 env=self._goma_ctl_env, 143 env=self._goma_ctl_env,
144 stdout=self.m.raw_io.output(),
145 step_test_data=( 144 step_test_data=(
146 lambda: self.m.raw_io.test_api.stream_output('12345')), 145 lambda: self.m.raw_io.test_api.output('12345')),
147 infra_step=True) 146 infra_step=True)
148 147
149 self._cloudtail_pid = step_result.stdout
150
151 def _stop_cloudtail(self): 148 def _stop_cloudtail(self):
152 """Stop cloudtail started by _start_cloudtail 149 """Stop cloudtail started by _start_cloudtail
153 150
154 Raises: 151 Raises:
155 InfraFailure if it fails to stop cloudtail 152 InfraFailure if it fails to stop cloudtail
156 """ 153 """
157 154
158 assert self._cloudtail_pid is not None
159
160 self.m.python( 155 self.m.python(
161 name='stop cloudtail', 156 name='stop cloudtail',
162 script=self.resource('cloudtail_utils.py'), 157 script=self.resource('cloudtail_utils.py'),
163 args=['stop', 158 args=['stop',
164 '--killed-pid', self._cloudtail_pid], 159 '--killed-pid-file', self.m.path['tmp_base'].join('pid.txt')],
ukai 2016/09/29 07:55:01 cloudtail.pid?
tikuta 2016/09/29 08:00:50 Done.
165 infra_step=True) 160 infra_step=True)
166 161
167 self._cloudtail_pid = None 162 self._cloudtail_pid = None
168 163
169 def start(self, env=None, **kwargs): 164 def start(self, env=None, **kwargs):
170 """Start goma compiler_proxy. 165 """Start goma compiler_proxy.
171 166
172 A user MUST execute ensure_goma beforehand. 167 A user MUST execute ensure_goma beforehand.
173 It is user's responsibility to handle failure of starting compiler_proxy. 168 It is user's responsibility to handle failure of starting compiler_proxy.
174 """ 169 """
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 ninja_log_exit_status = e.retcode 320 ninja_log_exit_status = e.retcode
326 raise e 321 raise e
327 except self.m.step.InfraFailure as e: # pragma: no cover 322 except self.m.step.InfraFailure as e: # pragma: no cover
328 ninja_log_exit_status = -1 323 ninja_log_exit_status = -1
329 raise e 324 raise e
330 finally: 325 finally:
331 self.stop(ninja_log_outdir=ninja_log_outdir, 326 self.stop(ninja_log_outdir=ninja_log_outdir,
332 ninja_log_compiler=ninja_log_compiler, 327 ninja_log_compiler=ninja_log_compiler,
333 ninja_log_command=ninja_log_command, 328 ninja_log_command=ninja_log_command,
334 ninja_log_exit_status=ninja_log_exit_status) 329 ninja_log_exit_status=ninja_log_exit_status)
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/goma/example.expected/linux.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698