diff options
-rwxr-xr-x | bitbake/bin/bitbake | 10 | ||||
-rw-r--r-- | bitbake/lib/bb/server/xmlrpc.py | 33 |
2 files changed, 39 insertions, 4 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake index cca2b8d29b7..a0a2baa4bc6 100755 --- a/bitbake/bin/bitbake +++ b/bitbake/bin/bitbake @@ -302,6 +302,7 @@ def main(): # we start a stub server that is actually a XMLRPClient that connects to a real server server = servermodule.BitBakeXMLRPCClient(configParams.observe_only) server.saveConnectionDetails(configParams.remote_server) + server.saveConnectionConfigParams(configParams) if not configParams.server_only: # Collect the feature set for the UI @@ -312,11 +313,20 @@ def main(): server_connection = server.establishConnection(featureset) except: sys.exit(1) + if not server_connection: + sys.exit(1) server_connection.terminate() sys.exit(0) # Setup a connection to the server (cooker) server_connection = server.establishConnection(featureset) + if not server_connection: + if configParams.kill_server: + bb.fatal("Server already killed") + configParams.bind = configParams.remote_server + start_server(servermodule, configParams, configuration) + bb.event.ui_queue = [] + server_connection = server.establishConnection(featureset) # Restore the environment in case the UI needs it for k in cleanedvars: diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py index 82c0e8d8a69..3a67ab0cf27 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) |