aboutsummaryrefslogtreecommitdiffstats
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)
downloadopenembedded-core-contrib-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):
# if BBSERVER says to autodetect, let's do that
if options.remote_server:
- [host, port] = options.remote_server.split(":", 2)
- port = int(port)
+ port = -1
+ if options.remote_server != 'autostart':
+ host, port = options.remote_server.split(":", 2)
+ port = int(port)
# use automatic port if port set to -1, means read it from
# the bitbake.lock file; this is a bit tricky, but we always expect
# to be in the base of the build directory if we need to have a
@@ -321,17 +323,18 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
lf.close()
options.remote_server = remotedef
except Exception as e:
- raise BBMainException("Failed to read bitbake.lock (%s), invalid port" % str(e))
+ if options.remote_server != 'autostart':
+ raise BBMainException("Failed to read bitbake.lock (%s), invalid port" % str(e))
return options, targets[1:]
def start_server(servermodule, configParams, configuration, features):
server = servermodule.BitBakeServer()
- single_use = not configParams.server_only
+ single_use = not configParams.server_only and os.getenv('BBSERVER') != 'autostart'
if configParams.bind:
(host, port) = configParams.bind.split(':')
- server.initServer((host, int(port)), single_use)
+ server.initServer((host, int(port)), single_use=single_use)
configuration.interface = [server.serverImpl.host, server.serverImpl.port]
else:
server.initServer(single_use=single_use)
@@ -445,6 +448,14 @@ def bitbake_main(configParams, configuration):
server = start_server(servermodule, configParams, configuration, featureset)
bb.event.ui_queue = []
else:
+ if os.getenv('BBSERVER') == 'autostart':
+ if configParams.remote_server == 'autostart' or \
+ not servermodule.check_connection(configParams.remote_server, timeout=2):
+ configParams.bind = 'localhost:0'
+ srv = start_server(servermodule, configParams, configuration, featureset)
+ configParams.remote_server = '%s:%d' % tuple(configuration.interface)
+ bb.event.ui_queue = []
+
# we start a stub server that is actually a XMLRPClient that connects to a real server
server = servermodule.BitBakeXMLRPCClient(configParams.observe_only,
configParams.xmlrpctoken)