From b1cef60d76a1e3cb3b7b131a2fae74111ce2811b Mon Sep 17 00:00:00 2001 From: HKXluo Date: Sun, 4 May 2025 18:20:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E5=92=8C=E5=81=A5=E5=BA=B7=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 059b9b8..1051dbc 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ from flask import Flask, request, jsonify import threading import queue import time +import argparse from ffmpeg_utils import process_ffmpeg from sanjuuni_utils import process_sanjuuni from file_cleanup import start_cleanup_thread @@ -122,7 +123,22 @@ def download_file_endpoint(file_id, filename): logging.error(f"下载文件时出错: {e}") return jsonify({'status': 'error', 'error': str(e)}), 500 + + + + +@app.route('/health', methods=['GET']) +def health_check(): + """健康检查接口,直接返回 'ok'""" + return "OK" + + if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) + # 配置命令行参数解析 + parser = argparse.ArgumentParser(description='启动FFmpeg处理服务') + parser.add_argument('--port', type=int, default=5000, help='服务监听的端口号(默认: 5000)') + args = parser.parse_args() + + logging.info(f"启动应用程序,端口: {args.port}...") start_cleanup_thread() - app.run(debug=True) \ No newline at end of file + app.run(host='0.0.0.0', port=args.port, threaded=True) \ No newline at end of file