mirror of
https://git.yoctoproject.org/poky
synced 2026-04-20 00:32:13 +02:00
bitbake: 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] (Bitbake rev: bd6398e967c234e89d773f509512ebf460fa76ff) 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>
This commit is contained in:
committed by
Richard Purdie
parent
2687b245c2
commit
5a51fb28db
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user