mirror of
https://git.yoctoproject.org/poky
synced 2026-09-15 06:49:33 +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
|
from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
|
||||||
import threading
|
import threading
|
||||||
import Queue
|
import Queue
|
||||||
|
import socket
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import sqlite3
|
import sqlite3
|
||||||
@@ -37,7 +38,6 @@ singleton = None
|
|||||||
class PRServer(SimpleXMLRPCServer):
|
class PRServer(SimpleXMLRPCServer):
|
||||||
def __init__(self, dbfile, logfile, interface, daemon=True):
|
def __init__(self, dbfile, logfile, interface, daemon=True):
|
||||||
''' constructor '''
|
''' constructor '''
|
||||||
import socket
|
|
||||||
try:
|
try:
|
||||||
SimpleXMLRPCServer.__init__(self, interface,
|
SimpleXMLRPCServer.__init__(self, interface,
|
||||||
logRequests=False, allow_none=True)
|
logRequests=False, allow_none=True)
|
||||||
@@ -289,7 +289,8 @@ class PRServerConnection(object):
|
|||||||
return self.host, self.port
|
return self.host, self.port
|
||||||
|
|
||||||
def start_daemon(dbfile, host, port, logfile):
|
def start_daemon(dbfile, host, port, logfile):
|
||||||
pidfile = PIDPREFIX % (host, port)
|
ip = socket.gethostbyname(host)
|
||||||
|
pidfile = PIDPREFIX % (ip, port)
|
||||||
try:
|
try:
|
||||||
pf = file(pidfile,'r')
|
pf = file(pidfile,'r')
|
||||||
pid = int(pf.readline().strip())
|
pid = int(pf.readline().strip())
|
||||||
@@ -302,12 +303,14 @@ def start_daemon(dbfile, host, port, logfile):
|
|||||||
% pidfile)
|
% pidfile)
|
||||||
return 1
|
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()
|
server.start()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def stop_daemon(host, port):
|
def stop_daemon(host, port):
|
||||||
pidfile = PIDPREFIX % (host, port)
|
ip = socket.gethostbyname(host)
|
||||||
|
pidfile = PIDPREFIX % (ip, port)
|
||||||
try:
|
try:
|
||||||
pf = file(pidfile,'r')
|
pf = file(pidfile,'r')
|
||||||
pid = int(pf.readline().strip())
|
pid = int(pf.readline().strip())
|
||||||
@@ -320,7 +323,7 @@ def stop_daemon(host, port):
|
|||||||
% pidfile)
|
% pidfile)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
PRServerConnection(host, port).terminate()
|
PRServerConnection(ip, port).terminate()
|
||||||
except:
|
except:
|
||||||
logger.critical("Stop PRService %s:%d failed" % (host,port))
|
logger.critical("Stop PRService %s:%d failed" % (host,port))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user