summaryrefslogtreecommitdiff
path: root/poky/bitbake/lib/prserv/serv.py
diff options
context:
space:
mode:
authorAndrew Geissler <geissonator@yahoo.com>2020-04-13 21:39:40 +0300
committerAndrew Geissler <geissonator@yahoo.com>2020-05-05 16:30:44 +0300
commit82c905dc58a36aeae40b1b273a12f63fb1973cf4 (patch)
tree38caf00263451b5036435cdc36e035b25d32e623 /poky/bitbake/lib/prserv/serv.py
parent83ecb75644b3d677c274188f9ac0b2374d6f6925 (diff)
downloadopenbmc-82c905dc58a36aeae40b1b273a12f63fb1973cf4.tar.xz
meta-openembedded and poky: subtree updates
Squash of the following due to dependencies among them and OpenBMC changes: meta-openembedded: subtree update:d0748372d2..9201611135 meta-openembedded: subtree update:9201611135..17fd382f34 poky: subtree update:9052e5b32a..2e11d97b6c poky: subtree update:2e11d97b6c..a8544811d7 The change log was too large for the jenkins plugin to handle therefore it has been removed. Here is the first and last commit of each subtree: meta-openembedded:d0748372d2 cppzmq: bump to version 4.6.0 meta-openembedded:17fd382f34 mpv: Remove X11 dependency poky:9052e5b32a package_ipk: Remove pointless comment to trigger rebuild poky:a8544811d7 pbzip2: Fix license warning Change-Id: If0fc6c37629642ee207a4ca2f7aa501a2c673cd6 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'poky/bitbake/lib/prserv/serv.py')
-rw-r--r--poky/bitbake/lib/prserv/serv.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/poky/bitbake/lib/prserv/serv.py b/poky/bitbake/lib/prserv/serv.py
index b854ba14b..25dcf8a0e 100644
--- a/poky/bitbake/lib/prserv/serv.py
+++ b/poky/bitbake/lib/prserv/serv.py
@@ -292,10 +292,9 @@ class PRServer(SimpleXMLRPCServer):
logger.addHandler(streamhandler)
# write pidfile
- pid = str(os.getpid())
- pf = open(self.pidfile, 'w')
- pf.write("%s\n" % pid)
- pf.close()
+ pid = str(os.getpid())
+ with open(self.pidfile, 'w') as pf:
+ pf.write("%s\n" % pid)
self.work_forever()
self.delpid()
@@ -353,9 +352,8 @@ def start_daemon(dbfile, host, port, logfile):
ip = socket.gethostbyname(host)
pidfile = PIDPREFIX % (ip, port)
try:
- pf = open(pidfile,'r')
- pid = int(pf.readline().strip())
- pf.close()
+ with open(pidfile) as pf:
+ pid = int(pf.readline().strip())
except IOError:
pid = None
@@ -449,29 +447,35 @@ class PRServiceConfigError(Exception):
def auto_start(d):
global singleton
- # Shutdown any existing PR Server
- auto_shutdown()
-
host_params = list(filter(None, (d.getVar('PRSERV_HOST') or '').split(':')))
if not host_params:
+ # Shutdown any existing PR Server
+ auto_shutdown()
return None
if len(host_params) != 2:
+ # Shutdown any existing PR Server
+ auto_shutdown()
logger.critical('\n'.join(['PRSERV_HOST: incorrect format',
'Usage: PRSERV_HOST = "<hostname>:<port>"']))
raise PRServiceConfigError
- if is_local_special(host_params[0], int(host_params[1])) and not singleton:
+ if is_local_special(host_params[0], int(host_params[1])):
import bb.utils
cachedir = (d.getVar("PERSISTENT_DIR") or d.getVar("CACHE"))
if not cachedir:
logger.critical("Please set the 'PERSISTENT_DIR' or 'CACHE' variable")
raise PRServiceConfigError
- bb.utils.mkdirhier(cachedir)
dbfile = os.path.join(cachedir, "prserv.sqlite3")
logfile = os.path.join(cachedir, "prserv.log")
- singleton = PRServSingleton(os.path.abspath(dbfile), os.path.abspath(logfile), ("localhost",0))
- singleton.start()
+ if singleton:
+ if singleton.dbfile != dbfile:
+ # Shutdown any existing PR Server as doesn't match config
+ auto_shutdown()
+ if not singleton:
+ bb.utils.mkdirhier(cachedir)
+ singleton = PRServSingleton(os.path.abspath(dbfile), os.path.abspath(logfile), ("localhost",0))
+ singleton.start()
if singleton:
host, port = singleton.getinfo()
else: