diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-07-24 09:13:55 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-08-06 11:21:07 +0100 |
commit | a4fa8f1bd88995ae60e10430316fbed63d478587 (patch) | |
tree | 1e600d955490012da58985d0bdf06c5371781db7 /lib/bb/cooker.py | |
parent | 6a901bb904a97ca90d88be2c6901d3d32346282f (diff) | |
download | bitbake-a4fa8f1bd88995ae60e10430316fbed63d478587.tar.gz |
cooker/hashserv: Allow autostarting of a local hash server using BB_HASHSERVE
Its useful, particularly in the local developer model of usage, for
bitbake to start and stop a hash equivalence server on local port,
rather than relying on one being started by the user before the build.
The new BB_HASHSERVE variable supports this.
The database handling is moved internally into the hashserv code so that
different threads/processes can be used for the server without errors.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/cooker.py')
-rw-r--r-- | lib/bb/cooker.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py index b4851e13e..84f25ec94 100644 --- a/lib/bb/cooker.py +++ b/lib/bb/cooker.py @@ -31,6 +31,7 @@ import pyinotify import json import pickle import codecs +import hashserv logger = logging.getLogger("BitBake") collectlog = logging.getLogger("BitBake.Collection") @@ -230,6 +231,8 @@ class BBCooker: self.state = state.initial self.parser = None + self.hashserv = None + self.hashservport = None signal.signal(signal.SIGTERM, self.sigterm_exception) # Let SIGHUP exit as SIGTERM @@ -368,6 +371,15 @@ class BBCooker: self.data.setVar('BB_CMDLINE', self.ui_cmdline) + if self.data.getVar("BB_HASHSERVE") == "localhost:0": + dbfile = (self.data.getVar("PERSISTENT_DIR") or self.data.getVar("CACHE")) + "/hashserv.db" + self.hashserv = hashserv.create_server(('localhost', 0), dbfile, '') + self.hashservport = "localhost:" + str(self.hashserv.server_port) + thread = threading.Thread(target=self.hashserv.serve_forever) + thread.daemon = True + thread.start() + self.data.setVar("BB_HASHSERVE", self.hashservport) + # # Copy of the data store which has been expanded. # Used for firing events and accessing variables where expansion needs to be accounted for @@ -1645,9 +1657,10 @@ class BBCooker: def post_serve(self): prserv.serv.auto_shutdown() + if self.hashserv: + self.hashserv.shutdown() bb.event.fire(CookerExit(), self.data) - def shutdown(self, force = False): if force: self.state = state.forceshutdown |