2016-08-23 00:40:38 +08:00
|
|
|
from __future__ import print_function # In python 2.7
|
2016-08-02 04:54:41 +08:00
|
|
|
|
2015-09-29 22:01:09 +08:00
|
|
|
import os
|
2016-08-02 04:54:41 +08:00
|
|
|
import sys
|
2015-09-29 22:01:09 +08:00
|
|
|
|
2017-08-25 22:47:08 +08:00
|
|
|
BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
if BASE_PATH not in sys.path:
|
|
|
|
sys.path.insert(0, BASE_PATH)
|
|
|
|
|
|
|
|
from cc.app import init_app
|
|
|
|
from cc.utils import init_collections
|
2016-08-02 04:54:41 +08:00
|
|
|
|
2017-08-25 22:47:08 +08:00
|
|
|
ISLAND_PORT = 5000
|
|
|
|
DEFAULT_MONGO_URL = "mongodb://localhost:27017/monkeyisland"
|
2015-09-29 22:01:09 +08:00
|
|
|
|
2017-08-17 23:04:36 +08:00
|
|
|
INITIAL_USERNAMES = ['Administrator', 'root', 'user']
|
|
|
|
INITIAL_PASSWORDS = ["Password1!", "1234", "password", "12345678"]
|
|
|
|
|
2015-09-29 22:01:09 +08:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2016-08-01 01:40:05 +08:00
|
|
|
from tornado.wsgi import WSGIContainer
|
|
|
|
from tornado.httpserver import HTTPServer
|
|
|
|
from tornado.ioloop import IOLoop
|
|
|
|
|
2017-08-25 22:47:08 +08:00
|
|
|
app = init_app(os.environ.get('MONGO_URL', DEFAULT_MONGO_URL))
|
2017-08-17 23:04:36 +08:00
|
|
|
with app.app_context():
|
2017-08-25 22:47:08 +08:00
|
|
|
init_collections(INITIAL_USERNAMES, INITIAL_PASSWORDS)
|
|
|
|
http_server = HTTPServer(WSGIContainer(app),
|
|
|
|
ssl_options={'certfile': os.environ.get('SERVER_CRT', 'server.crt'),
|
|
|
|
'keyfile': os.environ.get('SERVER_KEY', 'server.key')})
|
2016-08-02 04:54:41 +08:00
|
|
|
http_server.listen(ISLAND_PORT)
|
2016-08-01 01:40:05 +08:00
|
|
|
IOLoop.instance().start()
|
2016-08-23 00:40:38 +08:00
|
|
|
# app.run(host='0.0.0.0', debug=True, ssl_context=('server.crt', 'server.key'))
|