可运行
This commit is contained in:
62
manager.py
62
manager.py
@@ -1,48 +1,26 @@
|
||||
# # -*- coding: utf-8 -*-
|
||||
# from application import app
|
||||
# from jobs.launcher import register_runjob_command # 导入注册函数
|
||||
# import click
|
||||
# import sys
|
||||
#
|
||||
# # 初始化任务命令(关键点)
|
||||
# register_runjob_command() # 注册 runjob 命令到 Flask CLI
|
||||
#
|
||||
# # 定义 Flask CLI 命令(服务启动)
|
||||
# @app.cli.command("runserver")
|
||||
# @click.option("--host", default="0.0.0.0", help="Server host")
|
||||
# @click.option("--port", default=app.config.get('SERVER_PORT', 8999), help="Server port")
|
||||
# def start_server(host, port):
|
||||
# """启动开发服务器"""
|
||||
# app.run(host=host, port=port, debug=True, use_reloader=True)
|
||||
#
|
||||
# if __name__ == '__main__':
|
||||
# if len(sys.argv) > 1 and sys.argv[1] == 'runserver':
|
||||
# app.run(host="0.0.0.0", port=app.config.get('SERVER_PORT', 8999), debug=True, use_reloader=True)
|
||||
# else:
|
||||
# app.cli.main()
|
||||
|
||||
|
||||
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
from application import app,manager
|
||||
from flask_script import Server
|
||||
from application import app
|
||||
import www
|
||||
from jobs.launcher import runJob
|
||||
from jobs.launcher import register_runjob_command
|
||||
import click
|
||||
import sys
|
||||
|
||||
##web server
|
||||
manager.add_command( "runserver", Server( host='0.0.0.0',port=app.config['SERVER_PORT'],use_debugger = True ,use_reloader = True) )
|
||||
# 初始化任务命令
|
||||
register_runjob_command()
|
||||
|
||||
#job entrance
|
||||
manager.add_command('runjob', runJob() )
|
||||
|
||||
def main():
|
||||
manager.run( )
|
||||
# 定义 Flask CLI 命令(服务启动)
|
||||
@app.cli.command("runserver")
|
||||
@click.option("--host", default="0.0.0.0", help="Server host")
|
||||
@click.option("--port", default=None, help="Server port")
|
||||
def start_server(host, port):
|
||||
"""启动开发服务器"""
|
||||
if port is None:
|
||||
port = app.config.get('SERVER_PORT', 8032)
|
||||
app.run(host=host, port=port, debug=app.config.get('DEBUG', False))
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
import sys
|
||||
sys.exit( main() )
|
||||
except Exception as e:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
if len(sys.argv) > 1 and sys.argv[1] == 'runserver':
|
||||
port = app.config.get('SERVER_PORT', 8032)
|
||||
app.run(host="0.0.0.0", port=port, debug=app.config.get('DEBUG', False))
|
||||
else:
|
||||
app.cli.main()
|
||||
Reference in New Issue
Block a user