summaryrefslogtreecommitdiff
path: root/service/pixelated/runserver.py
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-10-15 16:03:17 +0200
committerDuda Dornelles <ddornell@thoughtworks.com>2014-10-15 16:20:55 +0200
commit6ac2e7a4c23ef2798ca5b4ad0aa84a5fb7b371f8 (patch)
tree3c6e4a3e0ee846cac650d8db76f1697c8fbbee68 /service/pixelated/runserver.py
parent87628d040390defc2ae303c77f6811f07d7c15ce (diff)
moving things out of user_agent. now it is called runserver and only does basic app setup and delegates to other "classes".
Diffstat (limited to 'service/pixelated/runserver.py')
-rw-r--r--service/pixelated/runserver.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/service/pixelated/runserver.py b/service/pixelated/runserver.py
new file mode 100644
index 00000000..840d6621
--- /dev/null
+++ b/service/pixelated/runserver.py
@@ -0,0 +1,49 @@
+#
+# Copyright (c) 2014 ThoughtWorks, Inc.
+#
+# Pixelated is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pixelated is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import os.path
+import crochet
+from flask import Flask
+from pixelated.config import app_factory
+import pixelated.config.args as input_args
+import pixelated.bitmask_libraries.register as leap_register
+import pixelated.config.reactor_manager as reactor_manager
+
+
+app = Flask(__name__, static_url_path='', static_folder=app_factory.get_static_folder())
+
+
+def setup():
+ try:
+ args = input_args.parse()
+ debug_enabled = args.debug or os.environ.get('DEBUG', False)
+ reactor_manager.start_reactor(logging=debug_enabled)
+ crochet.setup()
+
+ app.config.from_pyfile(args.config)
+
+ if args.register:
+ server_name = app.config['LEAP_SERVER_NAME']
+ leap_register.register_new_user(args.register, server_name)
+ else:
+ app_factory.create_app(debug_enabled, app)
+ finally:
+ reactor_manager.stop_reactor_on_exit()
+
+
+if __name__ == '__main__':
+ setup()