Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print ZServer and XMRPC URLs on server startup (Plone 4). #105

Merged
merged 1 commit into from Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Expand Up @@ -10,7 +10,8 @@ Breaking changes:

New features:

- *add item here*
- Print the ZServer and XMLRPC URLs when starting up the server.
[jone]

Bug fixes:

Expand Down
21 changes: 21 additions & 0 deletions src/plone/app/robotframework/server.py
Expand Up @@ -51,6 +51,8 @@ def start(zope_layer_dotted_name):
listener.register_function(zsl.zodb_setup, 'zodb_setup')
listener.register_function(zsl.zodb_teardown, 'zodb_teardown')

print_urls(zsl.zope_layer, listener)

try:
listener.serve_forever()
finally:
Expand All @@ -62,6 +64,25 @@ def start(zope_layer_dotted_name):
print(READY("Zope 2 server stopped"))


def print_urls(zope_layer, xmlrpc_server):
"""Prints the urls with the chosen ports.

When using a port 0, the operating system chooses an open port.
When doing that it is helpful that the URLs with the chosen ports are printed to stdout.
"""

for layer in zope_layer.baseResolutionOrder:
# Walk up the testing layers and look for the first zserver in order to get the
# actual server name and server port.
zserver = getattr(layer, 'zserver', None)
if not zserver:
continue
print('ZSERVER: http://{}:{}'.format(zserver.server_name, zserver.server_port))
break

print('XMLRPC: http://{0}:{1}'.format(*xmlrpc_server.server_address))


def start_reload(zope_layer_dotted_name, reload_paths=('src',),
preload_layer_dotted_name='plone.app.testing.PLONE_FIXTURE',
extensions=None):
Expand Down