Commit 0803ac51 authored by wanli's avatar wanli

🐞 fix: 更新manager.py

parent e1dbe892
# -*- coding: utf-8 -*-
import click
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.web import Application, RequestHandler, FallbackHandler
from tornado.web import Application, FallbackHandler
from tornado.ioloop import IOLoop
from flask_script import Manager
from flask_migrate import Migrate
from application.app import create_app, db
from application.app import create_app
from application.config import config
from views.monitor import DeviceMessageHandler, WatchHandler, NotifyHandler
# 根据配置初始化app
app = create_app(config)
migrate = Migrate(app, db)
manager = Manager(app)
host, port = tuple(config.BIND.split(":"))
print("===============>", host, port)
@manager.command
@click.group()
def cli():
pass
@click.command()
def run():
"""
生产模式启动命令函数
......@@ -28,7 +29,7 @@ def run():
http_server.listen(int(port), address=host)
IOLoop.instance().start()
@manager.command
@click.command()
def debug():
"""
debug模式启动命令函数
......@@ -51,5 +52,8 @@ def debug():
# app.logger.setLevel(logging.DEBUG)
# app.run(debug=True, port=int(port), host=host)
cli.add_command(debug)
cli.add_command(run)
if __name__ == '__main__':
manager.run()
cli()
\ No newline at end of file
'''
Author: your name
Date: 2021-06-15 17:40:09
LastEditTime: 2021-06-30 18:09:51
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \evm-store\tools\resources\manager.py
'''
# -*- coding: utf-8 -*-
import click
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.web import Application, FallbackHandler
from tornado.ioloop import IOLoop
from flask_script import Manager
from flask_migrate import Migrate
from application.app import create_app, db
from application.app import create_app
from application.config import config
from views.monitor import DeviceMessageHandler, WatchHandler, NotifyHandler
# 根据配置初始化app
app = create_app(config)
migrate = Migrate(app, db)
manager = Manager(app)
@manager.command
host, port = tuple(config.BIND.split(":"))
print("===============>", host, port)
@click.group()
def cli():
pass
@click.command()
def run():
"""
生产模式启动命令函数
To use: python3 manager.py run
"""
# app.logger.setLevel(app.config.get('LOG_LEVEL', logging.INFO))
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(3000, address='127.0.0.1', xheaders=True)
http_server.listen(int(port), address=host)
IOLoop.instance().start()
@manager.command
@click.command()
def debug():
"""
debug模式启动命令函数
To use: python3 manager.py debug
"""
wsgi_app = WSGIContainer(app)
application = Application([
(r"/api/v1/evm_store/monitor", DeviceMessageHandler),
(r"/api/v1/evm_store/watch", WatchHandler),
(r"/ws/v1/notify", NotifyHandler),
(r'.*', FallbackHandler, dict(fallback=wsgi_app))
])
application.listen(int(port), address=host)
IOLoop.current().start()
print("WebSocket Service Started......")
# app.logger.setLevel(logging.DEBUG)
app.run(debug=True, port=3000, host='127.0.0.1')
# app.run(debug=True, port=int(port), host=host)
cli.add_command(debug)
cli.add_command(run)
if __name__ == '__main__':
manager.run()
cli()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment