Skip to content

Commit

Permalink
adding host attribute to config file, server.py, and launch.py. closes
Browse files Browse the repository at this point in the history
  • Loading branch information
JaimieMurdock committed Mar 7, 2015
1 parent cebf862 commit 7bad63a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def is_valid_filepath(parser, arg):
'ca_certs' : None,
'ssl' : False,
'port' : '8{0:03d}',
'host' : '0.0.0.0',
'icons': 'link',
'corpus_link' : None,
'doc_title_format' : None,
Expand Down Expand Up @@ -70,7 +71,8 @@ def get_log_file(k):
print "pid","port"
for proc,k in zip(procs, topic_range):
port = config.get("main","port").format(k)
print proc.pid, "http://localhost:{0}/".format(port)
host = config.get("main","host")
print proc.pid, "http://{host}:{port}/".format(host=host,port=port)


# CLEAN EXIT AND SHUTDOWN OF SERVERS
Expand Down
12 changes: 10 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def is_valid_filepath(parser, arg):
help="Number of Topics")
parser.add_argument('-p', dest='port', type=int,
help="Port Number", default=None)
parser.add_argument('--host', default=None, help='Hostname')
parser.add_argument('--ssl', action='store_true',
help="Use SSL (must specify certfile, keyfile, and ca_certs in config)")
parser.add_argument('--ssl-certfile', dest='certfile', nargs="?",
Expand All @@ -202,6 +203,7 @@ def is_valid_filepath(parser, arg):
'ca_certs' : None,
'ssl' : False,
'port' : '8{0:03d}',
'host' : '0.0.0.0',
'topic_range' : '{0},{1},1'.format(args.k, args.k+1),
'icons': 'link',
'corpus_link' : None,
Expand All @@ -225,6 +227,12 @@ def is_valid_filepath(parser, arg):
port = config.get('main','port').format(args.k)
print port

# hostname assignment
if args.host:
host = args.host
else:
host = config.get('main','host')

# LDA objects
lda_c = Corpus.load(corpus_file)
lda_m = None
Expand Down Expand Up @@ -295,8 +303,8 @@ def send_static(filename):
keyfile = args.keyfile or config.get('ssl', 'keyfile')
ca_certs = args.ca_certs or config.get('ssl', 'ca_certs')

run(host='0.0.0.0', port=port, server=SSLWSGIRefServer,
run(host=host, port=port, server=SSLWSGIRefServer,
certfile=certfile, keyfile=keyfile, ca_certs=ca_certs)
else:
run(host='0.0.0.0', port=port)
run(host=host, port=port)

1 change: 1 addition & 0 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def build_models(corpus_filename, model_path, krange, n_iterations=200,
config.set("main", "context_type", corpus_type)
config.set("main", "model_pattern", model_pattern)
config.set("main", "port", "16{0:03d}")
config.set("main", "host", "0.0.0.0")
args.k.sort()
config.set("main", "topics", args.k)
config.add_section("www")
Expand Down

0 comments on commit 7bad63a

Please sign in to comment.