Attempt to daemonize port server

pull/3801/head
Craig Tiller 9 years ago
parent f0a293ed67
commit d2c39713bc
  1. 11
      tools/run_tests/port_server.py
  2. 12
      tools/run_tests/run_tests.py

@ -42,7 +42,7 @@ import time
# increment this number whenever making a change to ensure that
# the changes are picked up by running CI servers
# note that all changes must be backwards compatible
_MY_VERSION = 4
_MY_VERSION = 5
if len(sys.argv) == 2 and sys.argv[1] == 'dump_version':
@ -124,9 +124,12 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
self.send_header('Content-Type', 'text/plain')
self.end_headers()
p = int(self.path[6:])
del in_use[p]
pool.append(p)
self.log_message('drop port %d' % p)
if p in in_use:
del in_use[p]
pool.append(p)
self.log_message('drop known port %d' % p)
else:
self.log_message('drop unknown port %d' % p)
elif self.path == '/version_number':
# fetch a version string and the current process pid
self.send_response(200)

@ -709,9 +709,17 @@ def _start_port_server(port_server_port):
fd, logfile = tempfile.mkstemp()
os.close(fd)
print 'starting port_server, with log file %s' % logfile
port_server = subprocess.Popen(
[sys.executable, 'tools/run_tests/port_server.py', '-p', '%d' % port_server_port, '-l', logfile],
args = [sys.executable, 'tools/run_tests/port_server.py', '-p', '%d' % port_server_port, '-l', logfile]
if platform.system() == 'Windows':
port_server = subprocess.Popen(
args,
creationflags = 0x00000008, # detached process
close_fds=True)
else:
port_server = subprocess.Popen(
args,
preexec_fn=os.setsid,
close_fds=True)
time.sleep(1)
# ensure port server is up
waits = 0

Loading…
Cancel
Save