diff options
-rwxr-xr-x | bitbake/bin/bitbake | 76 |
1 files changed, 41 insertions, 35 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake index f44543de2c..6d4efe6bbf 100755 --- a/bitbake/bin/bitbake +++ b/bitbake/bin/bitbake | |||
@@ -195,6 +195,40 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters): | |||
195 | options, targets = parser.parse_args(sys.argv) | 195 | options, targets = parser.parse_args(sys.argv) |
196 | return options, targets[1:] | 196 | return options, targets[1:] |
197 | 197 | ||
198 | |||
199 | def start_server(servermodule, configParams, configuration): | ||
200 | server = servermodule.BitBakeServer() | ||
201 | if configParams.bind: | ||
202 | server.initServer((configParams.bind, 0)) | ||
203 | else: | ||
204 | server.initServer() | ||
205 | |||
206 | try: | ||
207 | configuration.setServerRegIdleCallback(server.getServerIdleCB()) | ||
208 | |||
209 | cooker = bb.cooker.BBCooker(configuration) | ||
210 | |||
211 | server.addcooker(cooker) | ||
212 | server.saveConnectionDetails() | ||
213 | except Exception as e: | ||
214 | exc_info = sys.exc_info() | ||
215 | while True: | ||
216 | try: | ||
217 | import queue | ||
218 | except ImportError: | ||
219 | import Queue as queue | ||
220 | try: | ||
221 | event = server.event_queue.get(block=False) | ||
222 | except (queue.Empty, IOError): | ||
223 | break | ||
224 | if isinstance(event, logging.LogRecord): | ||
225 | logger.handle(event) | ||
226 | raise exc_info[1], None, exc_info[2] | ||
227 | server.detach() | ||
228 | return server | ||
229 | |||
230 | |||
231 | |||
198 | def main(): | 232 | def main(): |
199 | 233 | ||
200 | configParams = BitBakeConfigParameters() | 234 | configParams = BitBakeConfigParameters() |
@@ -212,7 +246,7 @@ def main(): | |||
212 | 246 | ||
213 | try: | 247 | try: |
214 | module = __import__("bb.server", fromlist = [server_type]) | 248 | module = __import__("bb.server", fromlist = [server_type]) |
215 | server = getattr(module, server_type) | 249 | servermodule = getattr(module, server_type) |
216 | except AttributeError: | 250 | except AttributeError: |
217 | sys.exit("FATAL: Invalid server type '%s' specified.\n" | 251 | sys.exit("FATAL: Invalid server type '%s' specified.\n" |
218 | "Valid interfaces: xmlrpc, process [default]." % servertype) | 252 | "Valid interfaces: xmlrpc, process [default]." % servertype) |
@@ -241,42 +275,14 @@ def main(): | |||
241 | # Clear away any spurious environment variables while we stoke up the cooker | 275 | # Clear away any spurious environment variables while we stoke up the cooker |
242 | cleanedvars = bb.utils.clean_environment() | 276 | cleanedvars = bb.utils.clean_environment() |
243 | 277 | ||
244 | server = server.BitBakeServer() | 278 | # Collect all the caches we need |
245 | if configParams.bind: | 279 | if configParams.server_only: |
246 | server.initServer((configParams.bind, 0)) | 280 | configuration.extra_caches = gather_extra_cache_data() |
247 | else: | 281 | else: |
248 | server.initServer() | 282 | configuration.extra_caches = getattr(ui_module, "extraCaches", []) |
249 | |||
250 | try: | ||
251 | configuration.setServerRegIdleCallback(server.getServerIdleCB()) | ||
252 | |||
253 | if configParams.server_only: | ||
254 | configuration.extra_caches = gather_extra_cache_data() | ||
255 | else: | ||
256 | configuration.extra_caches = getattr(ui_module, "extraCaches", []) | ||
257 | |||
258 | cooker = bb.cooker.BBCooker(configuration) | ||
259 | |||
260 | server.addcooker(cooker) | ||
261 | server.saveConnectionDetails() | ||
262 | except Exception as e: | ||
263 | exc_info = sys.exc_info() | ||
264 | while True: | ||
265 | try: | ||
266 | import queue | ||
267 | except ImportError: | ||
268 | import Queue as queue | ||
269 | try: | ||
270 | event = server.event_queue.get(block=False) | ||
271 | except (queue.Empty, IOError): | ||
272 | break | ||
273 | if isinstance(event, logging.LogRecord): | ||
274 | logger.handle(event) | ||
275 | raise exc_info[1], None, exc_info[2] | ||
276 | server.detach() | ||
277 | 283 | ||
278 | # Should no longer need to ever reference cooker | 284 | # we start a server with a given configuration |
279 | del cooker | 285 | server = start_server(servermodule, configParams, configuration) |
280 | 286 | ||
281 | logger.removeHandler(handler) | 287 | logger.removeHandler(handler) |
282 | 288 | ||