From 6ff9c9e39de57964ad7f711a77243a7049e9cada Mon Sep 17 00:00:00 2001 From: Jason Wessel Date: Mon, 25 Nov 2013 15:21:27 -0600 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/lib/bb/server/xmlrpc.py | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'bitbake/lib/bb/server') 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): def saveConnectionDetails(self, remote): self.remote = remote + def saveConnectionConfigParams(self, configParams): + self.configParams = configParams + def establishConnection(self, featureset): # The format of "remote" must be "server:port" try: [host, port] = self.remote.split(":") port = int(port) - except: - return None + except Exception as e: + bb.fatal("Failed to read remote definition (%s)" % str(e)) + + # use automatic port if port set to -1, meaning read it from + # the bitbake.lock file + if port == -1: + lock_location = "%s/bitbake.lock" % self.configParams.environment.get('BUILDDIR') + lock = bb.utils.lockfile(lock_location, False, False) + if lock: + # This means there is no server running which we can + # connect to on the local system. + bb.utils.unlockfile(lock) + return None + + try: + lf = open(lock_location, 'r') + remotedef = lf.readline() + [host, port] = remotedef.split(":") + port = int(port) + lf.close() + self.remote = remotedef + except Exception as e: + bb.fatal("Failed to read bitbake.lock (%s)" % str(e)) + # We need our IP for the server connection. We get the IP # by trying to connect with the server try: @@ -352,8 +377,8 @@ class BitBakeXMLRPCClient(BitBakeBaseServer): s.connect((host, port)) ip = s.getsockname()[0] s.close() - except: - return None + except Exception as e: + bb.fatal("Could not create socket for %s:%s (%s)" % (host, port, str(e))) try: self.serverImpl = XMLRPCProxyServer(host, port) self.connection = BitBakeXMLRPCServerConnection(self.serverImpl, (ip, 0), self.observer_only, featureset) -- cgit v1.2.3-54-g00ecf