Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
add address argument to heron-ui (#1256)
Browse files Browse the repository at this point in the history
* add address argument to heron-ui
  • Loading branch information
lukess authored and kramasamy committed Aug 15, 2016
1 parent c87074b commit 6c2e6bb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
5 changes: 5 additions & 0 deletions heron/ui/src/python/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ def add_arguments(parser):
metavar='(a url; path to tracker; default: "' + consts.DEFAULT_TRACKER_URL + '")',
default=consts.DEFAULT_TRACKER_URL)

parser.add_argument(
'--address',
metavar='(an string; address to listen; default: "' + consts.DEFAULT_ADDRESS + '")',
default=consts.DEFAULT_ADDRESS)

parser.add_argument(
'--port',
metavar='(an integer; port to listen; default: ' + str(consts.DEFAULT_PORT) + ')',
Expand Down
3 changes: 3 additions & 0 deletions heron/ui/src/python/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# limitations under the License.
''' consts.py '''

# default parameter - address for the web to ui to listen on
DEFAULT_ADDRESS = "0.0.0.0"

# default parameter - port for the web to ui to listen on
DEFAULT_PORT = 8889

Expand Down
15 changes: 9 additions & 6 deletions heron/ui/src/python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import logging
import os
import signal
import socket

import tornado.ioloop
import tornado.options
Expand Down Expand Up @@ -105,12 +104,14 @@ def __init__(self):
tornado.web.Application.__init__(self, callbacks, **settings)


def define_options(port, tracker_url):
def define_options(address, port, tracker_url):
'''
:param address:
:param port:
:param tracker_url:
:return:
'''
define("address", default=address)
define("port", default=port)
define("tracker_url", default=tracker_url)

Expand All @@ -134,14 +135,16 @@ def main():

# log additional information
command_line_args = vars(parsed_args)
address = socket.gethostbyname(socket.gethostname())
Log.info("Listening at http://%s:%d", address, command_line_args['port'])

Log.info("Listening at http://%s:%d", command_line_args['address'], command_line_args['port'])
Log.info("Using tracker url: %s", command_line_args['tracker_url'])

# pass the options to tornado and start the ui server
define_options(command_line_args['port'], command_line_args['tracker_url'])
define_options(command_line_args['address'],
command_line_args['port'],
command_line_args['tracker_url'])
http_server = tornado.httpserver.HTTPServer(Application())
http_server.listen(command_line_args['port'])
http_server.listen(command_line_args['port'], address=command_line_args['address'])

# pylint: disable=unused-argument
# stop Tornado IO loop
Expand Down

0 comments on commit 6c2e6bb

Please sign in to comment.