summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2013-11-25 15:21:27 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-12-02 11:28:27 +0000
commit6ff9c9e39de57964ad7f711a77243a7049e9cada (patch)
treefce7119ba7d8e48a7ab1dfafd16b18244ddb6a80
parent0bea372b0fe6d77b2f6b742214f97a0db79e3990 (diff)
downloadpoky-6ff9c9e39de57964ad7f711a77243a7049e9cada.tar.gz
bitbake: bitbake, xmlrpc.py: Implement memory resident auto port configuration/restart
This patch adds the ability to dynamically select a port for the bitbake memory resident server when the BBSERVER port is set to -1. This allows for running multiple instances of the bitbake memory resident server on the same system in different build directories. The client portion of the bitbake instance can also request that the server automatically start when using the auto port feature. This is to deal with a bitbake instance that eventually times out and exits or that has died for some unknown reason. The new functionality allows for lazy startup of the server after sourcing the init script for the memory resident functionality. (Bitbake rev: d6abc07ff385357d312d8435b89e0a9c1f965433) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xbitbake/bin/bitbake10
-rw-r--r--bitbake/lib/bb/server/xmlrpc.py33
2 files changed, 39 insertions, 4 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index cca2b8d29b..a0a2baa4bc 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -302,6 +302,7 @@ def main():
302 # we start a stub server that is actually a XMLRPClient that connects to a real server 302 # we start a stub server that is actually a XMLRPClient that connects to a real server
303 server = servermodule.BitBakeXMLRPCClient(configParams.observe_only) 303 server = servermodule.BitBakeXMLRPCClient(configParams.observe_only)
304 server.saveConnectionDetails(configParams.remote_server) 304 server.saveConnectionDetails(configParams.remote_server)
305 server.saveConnectionConfigParams(configParams)
305 306
306 if not configParams.server_only: 307 if not configParams.server_only:
307 # Collect the feature set for the UI 308 # Collect the feature set for the UI
@@ -312,11 +313,20 @@ def main():
312 server_connection = server.establishConnection(featureset) 313 server_connection = server.establishConnection(featureset)
313 except: 314 except:
314 sys.exit(1) 315 sys.exit(1)
316 if not server_connection:
317 sys.exit(1)
315 server_connection.terminate() 318 server_connection.terminate()
316 sys.exit(0) 319 sys.exit(0)
317 320
318 # Setup a connection to the server (cooker) 321 # Setup a connection to the server (cooker)
319 server_connection = server.establishConnection(featureset) 322 server_connection = server.establishConnection(featureset)
323 if not server_connection:
324 if configParams.kill_server:
325 bb.fatal("Server already killed")
326 configParams.bind = configParams.remote_server
327 start_server(servermodule, configParams, configuration)
328 bb.event.ui_queue = []
329 server_connection = server.establishConnection(featureset)
320 330
321 # Restore the environment in case the UI needs it 331 # Restore the environment in case the UI needs it
322 for k in cleanedvars: 332 for k in cleanedvars:
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index 82c0e8d8a6..3a67ab0cf2 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -338,13 +338,38 @@ class BitBakeXMLRPCClient(BitBakeBaseServer):
338 def saveConnectionDetails(self, remote): 338 def saveConnectionDetails(self, remote):
339 self.remote = remote 339 self.remote = remote
340 340
341 def saveConnectionConfigParams(self, configParams):
342 self.configParams = configParams
343
341 def establishConnection(self, featureset): 344 def establishConnection(self, featureset):
342 # The format of "remote" must be "server:port" 345 # The format of "remote" must be "server:port"
343 try: 346 try:
344 [host, port] = self.remote.split(":") 347 [host, port] = self.remote.split(":")
345 port = int(port) 348 port = int(port)
346 except: 349 except Exception as e:
347 return None 350 bb.fatal("Failed to read remote definition (%s)" % str(e))
351
352 # use automatic port if port set to -1, meaning read it from
353 # the bitbake.lock file
354 if port == -1:
355 lock_location = "%s/bitbake.lock" % self.configParams.environment.get('BUILDDIR')
356 lock = bb.utils.lockfile(lock_location, False, False)
357 if lock:
358 # This means there is no server running which we can
359 # connect to on the local system.
360 bb.utils.unlockfile(lock)
361 return None
362
363 try:
364 lf = open(lock_location, 'r')
365 remotedef = lf.readline()
366 [host, port] = remotedef.split(":")
367 port = int(port)
368 lf.close()
369 self.remote = remotedef
370 except Exception as e:
371 bb.fatal("Failed to read bitbake.lock (%s)" % str(e))
372
348 # We need our IP for the server connection. We get the IP 373 # We need our IP for the server connection. We get the IP
349 # by trying to connect with the server 374 # by trying to connect with the server
350 try: 375 try:
@@ -352,8 +377,8 @@ class BitBakeXMLRPCClient(BitBakeBaseServer):
352 s.connect((host, port)) 377 s.connect((host, port))
353 ip = s.getsockname()[0] 378 ip = s.getsockname()[0]
354 s.close() 379 s.close()
355 except: 380 except Exception as e:
356 return None 381 bb.fatal("Could not create socket for %s:%s (%s)" % (host, port, str(e)))
357 try: 382 try:
358 self.serverImpl = XMLRPCProxyServer(host, port) 383 self.serverImpl = XMLRPCProxyServer(host, port)
359 self.connection = BitBakeXMLRPCServerConnection(self.serverImpl, (ip, 0), self.observer_only, featureset) 384 self.connection = BitBakeXMLRPCServerConnection(self.serverImpl, (ip, 0), self.observer_only, featureset)