diff options
author | Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> | 2015-09-10 11:59:45 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-09-28 12:00:33 +0100 |
commit | f78f90240a3041be426c6ba9085849352164ee8b (patch) | |
tree | a080520b78c2d191a0b2a459ff290c3d258c2781 /bitbake | |
parent | 134b267ebbcbf7a7bc43915e204da776530911d4 (diff) | |
download | poky-f78f90240a3041be426c6ba9085849352164ee8b.tar.gz |
bitbake: prserv/serv.py: Better messaging when starting/stopping the server with port=0
When starting the server using port=0, the server actually starts with a
different port, so print a message with this new value. When stopping the
server with port=0, advise the user which ports the server is listening to,
so next time it tries to close it, user can pick up the correct one.
[YOCTO #8560]
(Bitbake rev: 851e53a216682fc9133f51c05a24527cfc677741)
Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/prserv/serv.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py index c557837b83..eafc3aab7b 100644 --- a/bitbake/lib/prserv/serv.py +++ b/bitbake/lib/prserv/serv.py | |||
@@ -306,9 +306,16 @@ def start_daemon(dbfile, host, port, logfile): | |||
306 | server = PRServer(os.path.abspath(dbfile), os.path.abspath(logfile), (ip,port)) | 306 | server = PRServer(os.path.abspath(dbfile), os.path.abspath(logfile), (ip,port)) |
307 | server.start() | 307 | server.start() |
308 | 308 | ||
309 | # Sometimes, the port (i.e. localhost:0) indicated by the user does not match with | ||
310 | # the one the server actually is listening, so at least warn the user about it | ||
311 | _,rport = server.getinfo() | ||
312 | if port != rport: | ||
313 | sys.stdout.write("Server is listening at port %s instead of %s\n" | ||
314 | % (rport,port)) | ||
309 | return 0 | 315 | return 0 |
310 | 316 | ||
311 | def stop_daemon(host, port): | 317 | def stop_daemon(host, port): |
318 | import glob | ||
312 | ip = socket.gethostbyname(host) | 319 | ip = socket.gethostbyname(host) |
313 | pidfile = PIDPREFIX % (ip, port) | 320 | pidfile = PIDPREFIX % (ip, port) |
314 | try: | 321 | try: |
@@ -319,8 +326,20 @@ def stop_daemon(host, port): | |||
319 | pid = None | 326 | pid = None |
320 | 327 | ||
321 | if not pid: | 328 | if not pid: |
322 | sys.stderr.write("pidfile %s does not exist. Daemon not running?\n" | 329 | # when server starts at port=0 (i.e. localhost:0), server actually takes another port, |
323 | % pidfile) | 330 | # so at least advise the user which ports the corresponding server is listening |
331 | ports = [] | ||
332 | portstr = "" | ||
333 | for pf in glob.glob(PIDPREFIX % (ip,'*')): | ||
334 | bn = os.path.basename(pf) | ||
335 | root, _ = os.path.splitext(bn) | ||
336 | ports.append(root.split('_')[-1]) | ||
337 | if len(ports): | ||
338 | portstr = "Wrong port? Other ports listening at %s: %s" % (host, ' '.join(ports)) | ||
339 | |||
340 | sys.stderr.write("pidfile %s does not exist. Daemon not running? %s\n" | ||
341 | % (pidfile,portstr)) | ||
342 | return 1 | ||
324 | 343 | ||
325 | try: | 344 | try: |
326 | PRServerConnection(ip, port).terminate() | 345 | PRServerConnection(ip, port).terminate() |