[OE-core] [PATCH v2 1/3] prserv/serv: Start/Stop daemon using ip instead of host
leonardo.sandoval.gonzalez at linux.intel.com
leonardo.sandoval.gonzalez at linux.intel.com
Thu Sep 24 08:52:51 UTC 2015
From: Leonardo Sandoval <leonardo.sandoval.gonzalez at linux.intel.com>
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 at linux.intel.com>
---
bitbake/lib/prserv/serv.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index 0507485..0d96963 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/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)
@@ -261,7 +261,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())
@@ -274,12 +275,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())
@@ -292,7 +295,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))
--
1.8.4.5
More information about the Openembedded-core
mailing list