Patchwork [bitbake-devel] prserv: Adapt autostart to bitbake-worker

login
register
mail settings
Submitter Richard Purdie
Date June 7, 2013, 5:13 p.m.
Message ID <1370625214.6864.55.camel@ted>
Download mbox | patch
Permalink /patch/51355/
State New
Headers show

Comments

Richard Purdie - June 7, 2013, 5:13 p.m.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---

Patch

diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
index 8edf8dd..6580078 100755
--- a/bitbake/bin/bitbake-worker
+++ b/bitbake/bin/bitbake-worker
@@ -280,6 +280,7 @@  class BitbakeWorker(object):
         bb.msg.loggerDefaultVerbose = self.workerdata["logdefaultverbose"]
         bb.msg.loggerVerboseLogs = self.workerdata["logdefaultverboselogs"]
         bb.msg.loggerDefaultDomains = self.workerdata["logdefaultdomain"]
+        self.data.setVar("PRSERV_HOST", self.workerdata["prhost"])
 
     def handle_ping(self, _):
         workerlog_write("Handling ping\n")
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 77273dc..f375a6f 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -1177,7 +1177,7 @@  class BBCooker:
         # necessary from the data store.
         #bb.utils.empty_environment()
         try:
-            prserv.serv.auto_start(self.data)
+            self.prhost = prserv.serv.auto_start(self.data)
         except prserv.serv.PRServiceConfigError:
             bb.event.fire(CookerExit(), self.event_data)
         return
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index 577f04a..bd42538 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -831,6 +831,7 @@  class RunQueue:
             "logdefaultverbose" : bb.msg.loggerDefaultVerbose,
             "logdefaultverboselogs" : bb.msg.loggerVerboseLogs,
             "logdefaultdomain" : bb.msg.loggerDefaultDomains,
+            "prhost" : self.cooker.prhost,
         }
 
         worker.stdin.write("<cookerconfig>" + pickle.dumps(self.cooker.configuration) + "</cookerconfig>")
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index d7ab9ee..7f9331d 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -207,6 +207,9 @@  class PRServerConnection():
     def importone(self, version, pkgarch, checksum, value):
         return self.connection.importone(version, pkgarch, checksum, value)
 
+    def getinfo(self):
+        return self.host, self.port
+
 def start_daemon(dbfile, host, port, logfile):
     pidfile = PIDPREFIX % (host, port)
     try:
@@ -271,7 +274,7 @@  def auto_start(d):
 
     host_params = filter(None, (d.getVar('PRSERV_HOST', True) or '').split(':'))
     if not host_params:
-        return True
+        return None
 
     if len(host_params) != 2:
         logger.critical('\n'.join(['PRSERV_HOST: incorrect format',
@@ -296,7 +299,11 @@  def auto_start(d):
         port = int(host_params[1])
 
     try:
-        return PRServerConnection(host,port).ping()
+        connection = PRServerConnection(host,port)
+        connection.ping()
+        realhost, realport = connection.getinfo()
+        return str(realhost) + ":" + str(realport)
+        
     except Exception:
         logger.critical("PRservice %s:%d not available" % (host, port))
         raise PRServiceConfigError