104
103
# The URL that a commit done on the same machine as the server will
105
104
# have within the servers space. (e.g. file:///home/user/source)
106
105
# The URL that will be given to other hooks in the same process -
107
# the URL of the backing transport itself. (e.g. chroot+:///)
106
# the URL of the backing transport itself. (e.g. filtered-36195:///)
108
107
# We need all three because:
109
108
# * other machines see the first
110
109
# * local commits on this machine should be able to be mapped to
178
177
def get_url(self):
179
178
"""Return the url of the server"""
180
return "bzr://%s:%d/" % self._sockname
179
return "bzr://%s:%s/" % (self._sockname[0], self._sockname[1])
182
181
def serve_conn(self, conn, thread_name_suffix):
183
182
# For WIN32, where the timeout value from the listening socket
240
239
These are all empty initially, because by default nothing should get
244
self.create_hook(HookPoint('server_started',
242
Hooks.__init__(self, "bzrlib.smart.server", "SmartTCPServer.hooks")
243
self.add_hook('server_started',
245
244
"Called by the bzr server when it starts serving a directory. "
246
245
"server_started is called with (backing urls, public url), "
247
246
"where backing_url is a list of URLs giving the "
248
247
"server-specific directory locations, and public_url is the "
249
"public URL for the directory being served.", (0, 16), None))
250
self.create_hook(HookPoint('server_started_ex',
248
"public URL for the directory being served.", (0, 16))
249
self.add_hook('server_started_ex',
251
250
"Called by the bzr server when it starts serving a directory. "
252
251
"server_started is called with (backing_urls, server_obj).",
254
self.create_hook(HookPoint('server_stopped',
253
self.add_hook('server_stopped',
255
254
"Called by the bzr server when it stops serving a directory. "
256
255
"server_stopped is called with the same parameters as the "
257
"server_started hook: (backing_urls, public_url).", (0, 16), None))
256
"server_started hook: (backing_urls, public_url).", (0, 16))
257
self.add_hook('server_exception',
258
"Called by the bzr server when an exception occurs. "
259
"server_exception is called with the sys.exc_info() tuple "
260
"return true for the hook if the exception has been handled, "
261
"in which case the server will exit normally.", (2, 4))
259
263
SmartTCPServer.hooks = SmartServerHooks()
387
390
bzr_server.set_up(transport, host, port, inet)
388
391
bzr_server.smart_server.serve()
393
hook_caught_exception = False
394
for hook in SmartTCPServer.hooks['server_exception']:
395
hook_caught_exception = hook(sys.exc_info())
396
if not hook_caught_exception:
390
399
bzr_server.tear_down()