Skip to content

Commit

Permalink
be able to, with commands, override the port to run the server on
Browse files Browse the repository at this point in the history
  • Loading branch information
vangheem committed May 13, 2017
1 parent 63865c6 commit 6e5b2f3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions guillotina/commands/server.py
Expand Up @@ -28,26 +28,34 @@ def get_parser(self):
parser.add_argument('-r', '--reload', action='store_true',
dest='reload', help='Auto reload on code changes',
default=False)
parser.add_argument('-p', '--profile', action='store_true',
parser.add_argument('--profile', action='store_true',
dest='profile', help='Profile execution',
default=False)
parser.add_argument('--profile-output',
help='Where to store the output of the profile data',
default=None)
parser.add_argument('--port',
help='Override port to run this server on',
default=None, type=int)
parser.add_argument('--host',
help='Override host to run this server on',
default=None)
return parser

def _run(self, arguments, settings, app):
port = settings.get('address', settings.get('port'))
port = arguments.port or settings.get('address', settings.get('port'))
host = arguments.host or settings.get('host', '0.0.0.0')
if arguments.profile:
cProfile.runctx("web.run_app(app, host=settings.get('host', '0.0.0.0'), port=port)", {
cProfile.runctx("web.run_app(app, host=host, port=port)", {
'web': web
}, {
'port': port,
'host': host,
'settings': settings,
'app': app
}, filename=arguments.profile_output)
else:
web.run_app(app, host=settings.get('host', '0.0.0.0'), port=port)
web.run_app(app, host=host, port=port)

def run(self, arguments, settings, app):
if arguments.monitor:
Expand Down

0 comments on commit 6e5b2f3

Please sign in to comment.