[oe-commits] [bitbake] 01/02: bitbake: Extra server startup debugging
git at git.openembedded.org
git at git.openembedded.org
Wed Dec 5 13:12:57 UTC 2018
This is an automated email from the git hooks/post-receive script.
rpurdie pushed a commit to branch master-next
in repository bitbake.
commit 2dca8b6002054f2227474f4d4ed92602a1c5f9b2
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Fri Nov 30 17:02:02 2018 +0000
bitbake: Extra server startup debugging
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
lib/bb/cooker.py | 31 ++++++++++++++++++++++++++++++-
lib/bb/daemonize.py | 13 +++++++++++++
lib/bb/server/process.py | 41 ++++++++++++++++++++++++++++++++++++-----
3 files changed, 79 insertions(+), 6 deletions(-)
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 16681ba..a89c9a8 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -157,6 +157,14 @@ class EventWriter:
# queue all events until the file is inited
self.event_queue.append(event)
+import time
+
+def logit(logfile, msg):
+ if not logfile:
+ return
+ with open(logfile + "A", 'a+') as f:
+ f.write(msg + " %s %s\n" % (os.getpid(), time.time()))
+
#============================================================================#
# BBCooker
#============================================================================#
@@ -165,7 +173,8 @@ class BBCooker:
Manages one bitbake build run
"""
- def __init__(self, configuration, featureSet=None):
+ def __init__(self, configuration, featureSet=None, logfile=None):
+ logit(logfile, "Here R1")
self.recipecaches = None
self.skiplist = {}
self.featureset = CookerFeatures()
@@ -173,6 +182,9 @@ class BBCooker:
for f in featureSet:
self.featureset.setFeature(f)
+
+ logit(logfile, "Here R2")
+
self.configuration = configuration
self.configwatcher = pyinotify.WatchManager()
@@ -182,20 +194,26 @@ class BBCooker:
self.watchmask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_CREATE | pyinotify.IN_DELETE | \
pyinotify.IN_DELETE_SELF | pyinotify.IN_MODIFY | pyinotify.IN_MOVE_SELF | \
pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO
+ logit(logfile, "Here R3")
self.watcher = pyinotify.WatchManager()
self.watcher.bbseen = []
self.watcher.bbwatchedfiles = []
self.notifier = pyinotify.Notifier(self.watcher, self.notifications)
+ logit(logfile, "Here R4")
# If being called by something like tinfoil, we need to clean cached data
# which may now be invalid
bb.parse.clear_cache()
bb.parse.BBHandler.cached_statements = {}
+ logit(logfile, "Here R5")
+
self.ui_cmdline = None
self.initConfigurationData()
+ logit(logfile, "Here R6")
+
# we log all events to a file if so directed
if self.configuration.writeeventlog:
# register the log file writer as UI Handler
@@ -203,14 +221,20 @@ class BBCooker:
EventLogWriteHandler = namedtuple('EventLogWriteHandler', ['event'])
bb.event.register_UIHhandler(EventLogWriteHandler(writer))
+ logit(logfile, "Here R7")
+
self.inotify_modified_files = []
def _process_inotify_updates(server, cooker, abort):
cooker.process_inotify_updates()
return 1.0
+ logit(logfile, "Here R8")
+
self.configuration.server_register_idlecallback(_process_inotify_updates, self)
+ logit(logfile, "Here R9")
+
# TOSTOP must not be set or our children will hang when they output
try:
fd = sys.stdout.fileno()
@@ -224,14 +248,19 @@ class BBCooker:
except UnsupportedOperation:
pass
+ logit(logfile, "Here R10")
+
self.command = bb.command.Command(self)
self.state = state.initial
self.parser = None
+ logit(logfile, "Here R11")
+
signal.signal(signal.SIGTERM, self.sigterm_exception)
# Let SIGHUP exit as SIGTERM
signal.signal(signal.SIGHUP, self.sigterm_exception)
+ logit(logfile, "Here R12")
def process_inotify_updates(self):
for n in [self.confignotifier, self.notifier]:
diff --git a/lib/bb/daemonize.py b/lib/bb/daemonize.py
index c937675..3b40c53 100644
--- a/lib/bb/daemonize.py
+++ b/lib/bb/daemonize.py
@@ -10,6 +10,12 @@ import sys
import io
import traceback
+import time
+
+def logit(logfile, msg):
+ with open(logfile + "A", 'a+') as f:
+ f.write(msg + " %s %s\n" % (os.getpid(), time.time()))
+
def createDaemon(function, logfile):
"""
Detach a process from the controlling terminal and run it in the
@@ -68,6 +74,8 @@ def createDaemon(function, logfile):
with open('/dev/null', 'r') as si:
os.dup2(si.fileno(), sys.stdin.fileno())
+ logit(logfile, "Here D")
+
try:
so = open(logfile, 'a+')
os.dup2(so.fileno(), sys.stdout.fileno())
@@ -79,11 +87,16 @@ def createDaemon(function, logfile):
# and there aren't two seperate buffers
sys.stderr = sys.stdout
+ logit(logfile, "Here E")
+
try:
function()
except Exception as e:
+ logit(logfile, "Here F")
traceback.print_exc()
finally:
+ logit(logfile, "Here G")
+
bb.event.print_ui_queue()
# os._exit() doesn't flush open files like os.exit() does. Manually flush
# stdout and stderr so that any logging output will be seen, particularly
diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index 49973d6..edd604b 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -140,7 +140,7 @@ class ProcessServer(multiprocessing.Process):
def disconnect_client(self, fds):
if not self.haveui:
return
- print("Disconnecting Client")
+ print("Disconnecting Client %s" % os.getpid())
fds.remove(self.controllersock)
fds.remove(self.command_channel)
bb.event.unregister_UIHhandler(self.event_handle, True)
@@ -153,7 +153,7 @@ class ProcessServer(multiprocessing.Process):
self.lastui = time.time()
self.cooker.clientComplete()
if self.timeout is None:
- print("No timeout, exiting.")
+ print("No timeout, exiting. %s" % os.getpid())
self.quit = True
while not self.quit:
@@ -363,6 +363,12 @@ class BitBakeProcessServerConnection(object):
self.connection.recv.close()
return
+import time
+
+def logit(logfile, msg):
+ with open(logfile + "A", 'a+') as f:
+ f.write(msg + " %s %s\n" % (os.getpid(), time.time()))
+
class BitBakeServer(object):
start_log_format = '--- Starting bitbake server pid %s at %s ---'
start_log_datetime_format = '%Y-%m-%d %H:%M:%S.%f'
@@ -381,6 +387,7 @@ class BitBakeServer(object):
# Place the log in the builddirectory alongside the lock file
logfile = os.path.join(os.path.dirname(self.bitbake_lock.name), "bitbake-cookerdaemon.log")
+ self.logfile = logfile
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
# AF_UNIX has path length issues so chdir here to workaround
@@ -394,13 +401,18 @@ class BitBakeServer(object):
os.set_inheritable(self.sock.fileno(), True)
startdatetime = datetime.datetime.now()
+ logit(logfile, "Here A")
bb.daemonize.createDaemon(self._startServer, logfile)
+ logit(logfile, "Here B")
self.sock.close()
self.bitbake_lock.close()
os.close(self.readypipein)
ready = ConnectionReader(self.readypipe)
- r = ready.poll(30)
+ r = ready.poll(5)
+ if not r:
+ bb.note("Bitbake server didn't start within 5 seconds, waiting for 30")
+ r = ready.poll(30)
if r:
try:
r = ready.get()
@@ -438,28 +450,47 @@ class BitBakeServer(object):
bb.error("Server didn't start, last 60 loglines (%s):\n%s" % (logfile, "".join(lastlines)))
else:
bb.error("%s doesn't exist" % logfile)
-
+ if os.path.exists(logfile + "A"):
+ lastlines = []
+ with open(logfile + "A", "r") as f:
+ for line in f:
+ lastlines.append(line)
+ if len(lastlines) > 60:
+ lastlines = lastlines[-60:]
+ if lastlines:
+ bb.error("Second log, last 60 loglines (%s):\n%s" % (logfile + "A", "".join(lastlines)))
raise SystemExit(1)
ready.close()
def _startServer(self):
+ logit(self.logfile, "Here H")
+
print(self.start_log_format % (os.getpid(), datetime.datetime.now().strftime(self.start_log_datetime_format)))
sys.stdout.flush()
+ logit(self.logfile, "Here I")
+
server = ProcessServer(self.bitbake_lock, self.sock, self.sockname)
+ logit(self.logfile, "Here J")
self.configuration.setServerRegIdleCallback(server.register_idle_function)
os.close(self.readypipe)
writer = ConnectionWriter(self.readypipein)
- self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset)
+ logit(self.logfile, "Here K")
+ self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset, logfile=self.logfile)
+ logit(self.logfile, "Here L")
writer.send("r")
writer.close()
+ logit(self.logfile, "Here M")
+
server.cooker = self.cooker
server.server_timeout = self.configuration.server_timeout
server.xmlrpcinterface = self.configuration.xmlrpcinterface
print("Started bitbake server pid %d" % os.getpid())
sys.stdout.flush()
+ logit(self.logfile, "Here N")
+
server.start()
def connectProcessServer(sockname, featureset):
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list