distil/bin/web.py
Chris Forbes aec0e77d11 parse port option
Change-Id: I5eb546acea4bf64f46a8667338673c03187bbaf7
2014-04-04 08:50:36 +13:00

27 lines
680 B
Python

#!/usr/bin/python
from artifice.api import web
import yaml
import sys
import argparse
a = argparse.ArgumentParser("Web service for Artifice")
a.add_argument("-c", "--config", dest="config", help="Path to config file", default="/etc/artifice/conf.yaml")
a.add_argument("-i", "--interface", dest="ip", help="IP address to serve on.", default="0.0.0.0")
a.add_argument("-p", "--port", help="port to serve on", default="8000")
args = a.parse_args()
conf = None
try:
with open(args.config) as f:
conf = yaml.load(f)
except IOError as e:
print "Couldn't load config file: %s" % e
sys.exit(1)
app = web.get_app(conf)
app.run(host=args.ip, port=int(args.port))