Files
order/manager.py
2025-08-27 21:11:48 +08:00

48 lines
1.4 KiB
Python

# # -*- 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
import www
from jobs.launcher import runJob
##web server
manager.add_command( "runserver", Server( host='0.0.0.0',port=app.config['SERVER_PORT'],use_debugger = True ,use_reloader = True) )
#job entrance
manager.add_command('runjob', runJob() )
def main():
manager.run( )
if __name__ == '__main__':
try:
import sys
sys.exit( main() )
except Exception as e:
import traceback
traceback.print_exc()