summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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):
86 def work_forever(self,): 86 def work_forever(self,):
87 self.quit = False 87 self.quit = False
88 self.timeout = 0.5 88 self.timeout = 0.5
89 logger.info("PRServer: started! DBfile: %s, IP: %s, PORT: %s, PID: %s" % 89
90 logger.info("Started PRServer with DBfile: %s, IP: %s, PORT: %s, PID: %s" %
90 (self.dbfile, self.host, self.port, str(os.getpid()))) 91 (self.dbfile, self.host, self.port, str(os.getpid())))
91 92
92 while not self.quit: 93 while not self.quit:
@@ -97,7 +98,10 @@ class PRServer(SimpleXMLRPCServer):
97 return 98 return
98 99
99 def start(self): 100 def start(self):
100 self.daemonize() 101 pid = self.daemonize()
102 # Ensure both the parent sees this and the child from the work_forever log entry above
103 logger.info("Started PRServer with DBfile: %s, IP: %s, PORT: %s, PID: %s" %
104 (self.dbfile, self.host, self.port, str(pid)))
101 105
102 def delpid(self): 106 def delpid(self):
103 os.remove(self.pidfile) 107 os.remove(self.pidfile)
@@ -111,7 +115,7 @@ class PRServer(SimpleXMLRPCServer):
111 if pid > 0: 115 if pid > 0:
112 os.waitpid(pid, 0) 116 os.waitpid(pid, 0)
113 #parent return instead of exit to give control 117 #parent return instead of exit to give control
114 return 118 return pid
115 except OSError as e: 119 except OSError as e:
116 raise Exception("%s [%d]" % (e.strerror, e.errno)) 120 raise Exception("%s [%d]" % (e.strerror, e.errno))
117 121
@@ -139,14 +143,21 @@ class PRServer(SimpleXMLRPCServer):
139 os.dup2(so.fileno(),sys.stdout.fileno()) 143 os.dup2(so.fileno(),sys.stdout.fileno())
140 os.dup2(se.fileno(),sys.stderr.fileno()) 144 os.dup2(se.fileno(),sys.stderr.fileno())
141 145
146 # Ensure logging makes it to the logfile
147 streamhandler = logging.StreamHandler()
148 streamhandler.setLevel(logging.DEBUG)
149 formatter = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
150 streamhandler.setFormatter(formatter)
151 logger.addHandler(streamhandler)
152
142 # write pidfile 153 # write pidfile
143 atexit.register(self.delpid)
144 pid = str(os.getpid()) 154 pid = str(os.getpid())
145 pf = file(self.pidfile, 'w') 155 pf = file(self.pidfile, 'w')
146 pf.write("%s\n" % pid) 156 pf.write("%s\n" % pid)
147 pf.close() 157 pf.close()
148 158
149 self.work_forever() 159 self.work_forever()
160 self.delpid
150 os._exit(0) 161 os._exit(0)
151 162
152class PRServSingleton(): 163class PRServSingleton():
@@ -179,6 +190,7 @@ class PRServerConnection():
179 import socket 190 import socket
180 socket.setdefaulttimeout(2) 191 socket.setdefaulttimeout(2)
181 try: 192 try:
193 logger.info("Terminating PRServer...")
182 self.connection.quit() 194 self.connection.quit()
183 except Exception as exc: 195 except Exception as exc:
184 sys.stderr.write("%s\n" % str(exc)) 196 sys.stderr.write("%s\n" % str(exc))