Skip to content

Commit

Permalink
Merge pull request google#106 from rimey/add-host-option
Browse files Browse the repository at this point in the history
Add --host as a command line option.
  • Loading branch information
supriyagarg committed Aug 25, 2015
2 parents 9205241 + f668853 commit 951c0f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
18 changes: 0 additions & 18 deletions collector/cluster_insight.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

"""Select the module to run specified by CLUSTER_INSIGHT_MODE env. variable."""

import argparse
import os

import collector
Expand All @@ -26,23 +25,6 @@
import docker_proxy

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Cluster-Insight data collector')
parser.add_argument('-d', '--debug', action='store_true',
help='enable debug mode')
parser.add_argument('-p', '--port', action='store', type=int,
default=constants.DATA_COLLECTOR_PORT,
help=('data collector port number [default=%d]' %
constants.DATA_COLLECTOR_PORT))
parser.add_argument('--docker_port', action='store', type=int,
default=constants.DOCKER_PORT,
help=('Docker port number [default=%d]' %
constants.DOCKER_PORT))
parser.add_argument('-w', '--workers', action='store', type=int,
default=0,
help=('number of concurrent workers. A zero or a '
'negative value denotes an automatic calculation '
'of this number. [default=0]'))

mode = os.environ.get('CLUSTER_INSIGHT_MODE')

if mode == constants.MODE_MASTER:
Expand Down
16 changes: 8 additions & 8 deletions collector/collector.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -406,25 +406,25 @@ def get_health():
return flask.jsonify(utilities.make_response('OK', 'health'))


# Starts the web server and listen on all external IPs associated with this
# host.
def main():
"""Starts the web server."""
parser = argparse.ArgumentParser(description='Cluster-Insight data collector')
parser.add_argument('-d', '--debug', action='store_true',
help='enable debug mode')
parser.add_argument('--host', action='store', type=str,
default='0.0.0.0',
help='hostname to listen on [default=all interfaces]')
parser.add_argument('-p', '--port', action='store', type=int,
default=constants.DATA_COLLECTOR_PORT,
help=('data collector port number [default=%d]' %
constants.DATA_COLLECTOR_PORT))
help='data collector port number [default=%(default)d]')
parser.add_argument('--docker_port', action='store', type=int,
default=constants.DOCKER_PORT,
help=('Docker port number [default=%d]' %
constants.DOCKER_PORT))
help='Docker port number [default=%(default)d]')
parser.add_argument('-w', '--workers', action='store', type=int,
default=0,
help=('number of concurrent workers. A zero or a '
'negative value denotes an automatic calculation '
'of this number. [default=0]'))
'of this number. [default=%(default)d]'))
args = parser.parse_args()

app.logger.setLevel(logging.DEBUG if args.debug else logging.INFO)
Expand All @@ -435,7 +435,7 @@ def main():
g_state.set_num_workers(args.workers)
app.context_graph_global_state = g_state

app.run(host='0.0.0.0', port=args.port, debug=args.debug)
app.run(host=args.host, port=args.port, debug=args.debug)


if __name__ == '__main__':
Expand Down

0 comments on commit 951c0f2

Please sign in to comment.