aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-10-30 16:09:27 +0800
committerAaron LI <aaronly.me@outlook.com>2016-10-30 16:09:27 +0800
commite9c0f2aa8dc3d29c4c9c83f85744ce932230e130 (patch)
tree2b61bfa1ca1bcefecb8912d8dcf4fed4b5371014
parent90b877a2c785bb7691249d31e23138e0385001ae (diff)
downloadfg21sim-e9c0f2aa8dc3d29c4c9c83f85744ce932230e130.tar.bz2
webui: Add "bin/fg21sim-webui" to start the UI server
-rwxr-xr-xbin/fg21sim-webui51
-rwxr-xr-xsetup.py1
2 files changed, 52 insertions, 0 deletions
diff --git a/bin/fg21sim-webui b/bin/fg21sim-webui
new file mode 100755
index 0000000..225aeed
--- /dev/null
+++ b/bin/fg21sim-webui
@@ -0,0 +1,51 @@
+#!/usr/bin/env python3
+# -*- mode: python -*-
+#
+# Copyright (c) 2016 Weitian LI <liweitianux@live.com>
+# MIT license
+
+"""
+Start (and control) the Web user interface (UI) of "fg21sim",
+which is based upon Tornado_ and uses WebSocket_.
+
+.. _Tornado: http://www.tornadoweb.org/
+
+.. _WebSocket: https://en.wikipedia.org/wiki/WebSocket ,
+ http://caniuse.com/#feat=websockets
+"""
+
+
+import os
+import sys
+import argparse
+import logging
+
+import tornado.ioloop
+
+from fg21sim.configs import configs
+from fg21sim.utils import setup_logging
+from fg21sim.webui import make_application
+
+
+def main():
+ parser = argparse.ArgumentParser(description="Start the fg21sim Web UI")
+ parser.add_argument("-p", "--port", type=int, default=21127,
+ help="Tornado server listen port (default: 21127)")
+ parser.add_argument("-d", "--debug", action="store_true",
+ help="enable Tornado debug mode")
+ args = parser.parse_args()
+
+ setup_logging(dict_config=configs.logging)
+ tool = os.path.basename(sys.argv[0])
+ logger = logging.getLogger(tool)
+ logger.info("COMMAND: {0}".format(" ".join(sys.argv)))
+
+ application = make_application(debug=args.debug)
+ application.listen(args.port)
+ logger.info("Tornado started on: {protocol}://{host}:{port}".format(
+ protocol="http", host="localhost", port=args.port))
+ tornado.ioloop.IOLoop.current().start()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/setup.py b/setup.py
index ffa3627..6b0feb2 100755
--- a/setup.py
+++ b/setup.py
@@ -77,6 +77,7 @@ setup(
zip_safe=False,
scripts=[
"bin/fg21sim",
+ "bin/fg21sim-webui",
"bin/healpix2hpx",
"bin/hpx2healpix",
"bin/zea2healpix",