summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-06 23:18:19 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-06 23:45:36 +0000
commit1ef926cf788359b9845394bf95e298b7fcff4910 (patch)
treeebc490e516bd523b73485acc1815b7c4ca93cdb2 /bitbake
parentbdfc5207a0fdbed889c4a5997306adab82b1c2d4 (diff)
downloadpoky-1ef926cf788359b9845394bf95e298b7fcff4910.tar.gz
poky-1ef926cf788359b9845394bf95e298b7fcff4910.tar.bz2
poky-1ef926cf788359b9845394bf95e298b7fcff4910.zip
bitbake: prserv/serv.py: Fix logging in daemon mode
In deamon mode we need to ensure the logging module is sending log data to the log file. These changes ensure this happens correctly. (Bitbake rev: bb53b47710ca4579e20284668cb354f734c3d502) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/prserv/serv.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index 719941b32e..3489200536 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -86,7 +86,8 @@ class PRServer(SimpleXMLRPCServer):
def work_forever(self,):
self.quit = False
self.timeout = 0.5
- logger.info("PRServer: started! DBfile: %s, IP: %s, PORT: %s, PID: %s" %
+
+ logger.info("Started PRServer with DBfile: %s, IP: %s, PORT: %s, PID: %s" %
(self.dbfile, self.host, self.port, str(os.getpid())))
while not self.quit:
@@ -97,7 +98,10 @@ class PRServer(SimpleXMLRPCServer):
return
def start(self):
- self.daemonize()
+ pid = self.daemonize()
+ # Ensure both the parent sees this and the child from the work_forever log entry above
+ logger.info("Started PRServer with DBfile: %s, IP: %s, PORT: %s, PID: %s" %
+ (self.dbfile, self.host, self.port, str(pid)))
def delpid(self):
os.remove(self.pidfile)
@@ -111,7 +115,7 @@ class PRServer(SimpleXMLRPCServer):
if pid > 0:
os.waitpid(pid, 0)
#parent return instead of exit to give control
- return
+ return pid
except OSError as e:
raise Exception("%s [%d]" % (e.strerror, e.errno))
@@ -139,14 +143,21 @@ class PRServer(SimpleXMLRPCServer):
os.dup2(so.fileno(),sys.stdout.fileno())
os.dup2(se.fileno(),sys.stderr.fileno())
+ # Ensure logging makes it to the logfile
+ streamhandler = logging.StreamHandler()
+ streamhandler.setLevel(logging.DEBUG)
+ formatter = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
+ streamhandler.setFormatter(formatter)
+ logger.addHandler(streamhandler)
+
# write pidfile
- atexit.register(self.delpid)
pid = str(os.getpid())
pf = file(self.pidfile, 'w')
pf.write("%s\n" % pid)
pf.close()
self.work_forever()
+ self.delpid
os._exit(0)
class PRServSingleton():
@@ -179,6 +190,7 @@ class PRServerConnection():
import socket
socket.setdefaulttimeout(2)
try:
+ logger.info("Terminating PRServer...")
self.connection.quit()
except Exception as exc:
sys.stderr.write("%s\n" % str(exc))