summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/main.py
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-07-18 19:07:18 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-20 10:23:46 +0100
commit63ff759627fa7aa2325dcf373c078e7e47f7cc8c (patch)
treebd2bf2e349730cbce71f75a23f6482f1a1c354c4 /bitbake/lib/bb/main.py
parentb190c08b4866c5bfaca3bf8fc84c8ece486348d6 (diff)
downloadpoky-63ff759627fa7aa2325dcf373c078e7e47f7cc8c.tar.gz
bitbake: bitbake: main: implement server autostart feature
If environment variable BBSERVER == 'autostart' bitbake will automatically load server if it's not running yet. If host and port are in bitbake.lock then bitbake tries to check if server is running and responses to commands and starts new server only if this check fails. [YOCTO #5534] (Bitbake rev: 89c6e625d47303b2aad8e6645762f17aee01b2d4) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/main.py')
-rwxr-xr-xbitbake/lib/bb/main.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/bitbake/lib/bb/main.py b/bitbake/lib/bb/main.py
index 3fc3ff51e2..1c32e9308d 100755
--- a/bitbake/lib/bb/main.py
+++ b/bitbake/lib/bb/main.py
@@ -303,8 +303,10 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
303 303
304 # if BBSERVER says to autodetect, let's do that 304 # if BBSERVER says to autodetect, let's do that
305 if options.remote_server: 305 if options.remote_server:
306 [host, port] = options.remote_server.split(":", 2) 306 port = -1
307 port = int(port) 307 if options.remote_server != 'autostart':
308 host, port = options.remote_server.split(":", 2)
309 port = int(port)
308 # use automatic port if port set to -1, means read it from 310 # use automatic port if port set to -1, means read it from
309 # the bitbake.lock file; this is a bit tricky, but we always expect 311 # the bitbake.lock file; this is a bit tricky, but we always expect
310 # to be in the base of the build directory if we need to have a 312 # to be in the base of the build directory if we need to have a
@@ -321,17 +323,18 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
321 lf.close() 323 lf.close()
322 options.remote_server = remotedef 324 options.remote_server = remotedef
323 except Exception as e: 325 except Exception as e:
324 raise BBMainException("Failed to read bitbake.lock (%s), invalid port" % str(e)) 326 if options.remote_server != 'autostart':
327 raise BBMainException("Failed to read bitbake.lock (%s), invalid port" % str(e))
325 328
326 return options, targets[1:] 329 return options, targets[1:]
327 330
328 331
329def start_server(servermodule, configParams, configuration, features): 332def start_server(servermodule, configParams, configuration, features):
330 server = servermodule.BitBakeServer() 333 server = servermodule.BitBakeServer()
331 single_use = not configParams.server_only 334 single_use = not configParams.server_only and os.getenv('BBSERVER') != 'autostart'
332 if configParams.bind: 335 if configParams.bind:
333 (host, port) = configParams.bind.split(':') 336 (host, port) = configParams.bind.split(':')
334 server.initServer((host, int(port)), single_use) 337 server.initServer((host, int(port)), single_use=single_use)
335 configuration.interface = [server.serverImpl.host, server.serverImpl.port] 338 configuration.interface = [server.serverImpl.host, server.serverImpl.port]
336 else: 339 else:
337 server.initServer(single_use=single_use) 340 server.initServer(single_use=single_use)
@@ -445,6 +448,14 @@ def bitbake_main(configParams, configuration):
445 server = start_server(servermodule, configParams, configuration, featureset) 448 server = start_server(servermodule, configParams, configuration, featureset)
446 bb.event.ui_queue = [] 449 bb.event.ui_queue = []
447 else: 450 else:
451 if os.getenv('BBSERVER') == 'autostart':
452 if configParams.remote_server == 'autostart' or \
453 not servermodule.check_connection(configParams.remote_server, timeout=2):
454 configParams.bind = 'localhost:0'
455 srv = start_server(servermodule, configParams, configuration, featureset)
456 configParams.remote_server = '%s:%d' % tuple(configuration.interface)
457 bb.event.ui_queue = []
458
448 # we start a stub server that is actually a XMLRPClient that connects to a real server 459 # we start a stub server that is actually a XMLRPClient that connects to a real server
449 server = servermodule.BitBakeXMLRPCClient(configParams.observe_only, 460 server = servermodule.BitBakeXMLRPCClient(configParams.observe_only,
450 configParams.xmlrpctoken) 461 configParams.xmlrpctoken)