diff options
author | Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> | 2015-09-15 14:59:38 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-09-23 22:44:41 +0100 |
commit | bd6398e967c234e89d773f509512ebf460fa76ff (patch) | |
tree | 9ce9464136f3e82a3d8b0fb7ff381256842702e6 | |
parent | d3675cca419946cc19b3f280446fe1f656f11902 (diff) | |
download | bitbake-bd6398e967c234e89d773f509512ebf460fa76ff.zip |
prserv/serv: Start/Stop daemon using ip instead of host
In cases where hostname is given instead of an IP (i.e. localhost
instead of 127.0.0.1) when stopping the server with bitbake-prserv --stop,
the server shows a misleading message indicating that the daemon was not
found, where it is actually stopped. This patch converts host to IP values
before starting/stopping the daemon, so it will always work on IP, not on
hostnames, avoiding problems like the latter.
[YOCTO #8258]
Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/prserv/serv.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py index 5c0ffb99..3cb2e03d 100644 --- a/lib/prserv/serv.py +++ b/lib/prserv/serv.py @@ -3,6 +3,7 @@ import signal, time from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler import threading import Queue +import socket try: import sqlite3 @@ -37,7 +38,6 @@ singleton = None class PRServer(SimpleXMLRPCServer): def __init__(self, dbfile, logfile, interface, daemon=True): ''' constructor ''' - import socket try: SimpleXMLRPCServer.__init__(self, interface, logRequests=False, allow_none=True) @@ -289,7 +289,8 @@ class PRServerConnection(object): return self.host, self.port def start_daemon(dbfile, host, port, logfile): - pidfile = PIDPREFIX % (host, port) + ip = socket.gethostbyname(host) + pidfile = PIDPREFIX % (ip, port) try: pf = file(pidfile,'r') pid = int(pf.readline().strip()) @@ -302,12 +303,14 @@ def start_daemon(dbfile, host, port, logfile): % pidfile) return 1 - server = PRServer(os.path.abspath(dbfile), os.path.abspath(logfile), (host,port)) + server = PRServer(os.path.abspath(dbfile), os.path.abspath(logfile), (ip,port)) server.start() + return 0 def stop_daemon(host, port): - pidfile = PIDPREFIX % (host, port) + ip = socket.gethostbyname(host) + pidfile = PIDPREFIX % (ip, port) try: pf = file(pidfile,'r') pid = int(pf.readline().strip()) @@ -320,7 +323,7 @@ def stop_daemon(host, port): % pidfile) try: - PRServerConnection(host, port).terminate() + PRServerConnection(ip, port).terminate() except: logger.critical("Stop PRService %s:%d failed" % (host,port)) |