79
80
# settings, we have to somehow pass it a new config-on-disk to
81
82
self.socket_path = config.codehosting.forking_daemon_socket
83
command = [sys.executable, bzr_path, 'launchpad-forking-service',
84
'--path', self.socket_path, '-Derror']
82
85
process = subprocess.Popen(
83
[sys.executable, bzr_path, 'launchpad-forking-service',
84
'--path', self.socket_path,
85
], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
86
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
86
87
self.process = process
87
# Wait for it to indicate it is running
88
89
# The first line should be "Preloading" indicating it is ready
89
process.stderr.readline()
90
stderr.append(process.stderr.readline())
90
91
# The next line is the "Listening on socket" line
91
process.stderr.readline()
92
stderr.append(process.stderr.readline())
93
# Now it should be ready. If there were any errors, let's check, and
95
if (process.poll() is not None or
96
not stderr[1].strip().startswith('Listening on socket')):
97
if process.poll() is None:
98
time.sleep(1) # Give the traceback a chance to render.
99
os.kill(process.pid, signal.SIGTERM)
102
# Looks like there was a problem. We cannot use the "addDetail"
103
# method because this class is not a TestCase and does not have
104
# access to one. It runs as part of a layer. A "print" is the
105
# best we can do. That should still be visible on buildbot, which
106
# is where we have seen spurious failures so far.
109
print process.stdout.read()
112
print ''.join(stderr)
113
print process.stderr.read()
116
'Bzr server did not start correctly. See stdout and stderr '
117
'reported above. Command was "%s". PYTHONPATH was "%s". '
118
'BZR_PLUGIN_PATH was "%s".' %
120
env.get('PYTHONPATH'),
121
env.get('BZR_PLUGIN_PATH')))
94
123
def tearDown(self):
95
124
# SIGTERM is the graceful exit request, potentially we could wait a