From 94de65be3ae6677f0edd7c23e565e238a710793d Mon Sep 17 00:00:00 2001 From: gongzt Date: Mon, 5 Dec 2022 22:22:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E9=81=BF=E9=80=9A=E8=BF=87uwsgi?= =?UTF-8?q?=E5=90=AF=E5=8A=A8api=E6=9C=8D=E5=8A=A1=E6=97=B6=E5=81=B6?= =?UTF-8?q?=E7=8E=B0500=E6=88=96=E6=9F=A5=E8=AF=A2=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 0001-avoid-500-errors-by-uwsgi.patch | 98 ++++++++++++++++++++++++++++ aops-apollo.spec | 8 ++- 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 0001-avoid-500-errors-by-uwsgi.patch diff --git a/0001-avoid-500-errors-by-uwsgi.patch b/0001-avoid-500-errors-by-uwsgi.patch new file mode 100644 index 0000000..892e343 --- /dev/null +++ b/0001-avoid-500-errors-by-uwsgi.patch @@ -0,0 +1,98 @@ +From 53fa9132c94060f0f9a0285dd813af7805b28718 Mon Sep 17 00:00:00 2001 +From: gongzt +Date: Mon, 5 Dec 2022 21:57:29 +0800 +Subject: [PATCH] Avoid the occasional 500 or query error when the api service is started through uwsgi +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + aops-apollo.service | 3 +-- + apollo/manage.py | 23 +++++++++++++---------- + setup.py | 5 ++++- + 3 files changed, 18 insertions(+), 13 deletions(-) + +diff --git a/aops-apollo.service b/aops-apollo.service +index 45ab741..1b7dd6f 100644 +--- a/aops-apollo.service ++++ b/aops-apollo.service +@@ -4,8 +4,7 @@ After=network.target + + [Service] + Type=exec +-ExecStart=/usr/bin/aops-apollo start +-ExecStop=/usr/bin/aops-apollo stop ++ExecStart=/usr/bin/aops-apollo + Restart=on-failure + RestartSec=1 + RemainAfterExit=yes +diff --git a/apollo/manage.py b/apollo/manage.py +index a63f6a0..a367b27 100644 +--- a/apollo/manage.py ++++ b/apollo/manage.py +@@ -16,12 +16,12 @@ Author: + Description: Manager that start aops-manager + """ + from flask import Flask +-from flask_apscheduler import APScheduler ++# from flask_apscheduler import APScheduler + import sqlalchemy + + from apollo.conf import configuration + from apollo import BLUE_POINT +-from apollo.handler.task_handler.manager.scan_manager import TimedScanManager ++# from apollo.handler.task_handler.manager.scan_manager import TimedScanManager + from apollo.database import ENGINE + from apollo.database.table import create_vul_tables + from apollo.database.mapping import MAPPINGS +@@ -75,22 +75,25 @@ def init_app(): + app = Flask('apollo') + # limit max upload document size + app.config["MAX_CONTENT_LENGTH"] = 16 * 1024 * 1024 +- apscheduler = APScheduler() +- apscheduler.init_app(app) +- apscheduler.start() ++ # apscheduler = APScheduler() ++ # apscheduler.init_app(app) ++ # apscheduler.start() + + for blue, api in BLUE_POINT: + api.init_app(app) + app.register_blueprint(blue) + +- TimedScanManager.add_timed_task(app) ++ # TimedScanManager.add_timed_task(app) + return app + + +-init_database() +-app = init_app() +- +-if __name__ == "__main__": ++def main(): ++ init_database() ++ app = init_app() + ip = configuration.apollo.get('IP') + port = configuration.apollo.get('PORT') + app.run(host=ip, port=port) ++ ++ ++if __name__ == "__main__": ++ main() +diff --git a/setup.py b/setup.py +index 55d6406..83f2e2d 100644 +--- a/setup.py ++++ b/setup.py +@@ -33,6 +33,9 @@ setup( + ('/etc/aops', ['conf/apollo.ini']), + ('/usr/lib/systemd/system', ['aops-apollo.service']) + ], +- scripts=['aops-apollo'], ++ # scripts=['aops-apollo'], ++ entry_points={ ++ "console_scripts": ['aops-apollo=apollo.manage:main'] ++ }, + zip_safe=False + ) +-- +Gitee diff --git a/aops-apollo.spec b/aops-apollo.spec index 0f0d6f5..d188712 100644 --- a/aops-apollo.spec +++ b/aops-apollo.spec @@ -1,6 +1,6 @@ Name: aops-apollo Version: v1.1.1 -Release: 2 +Release: 3 Summary: Cve management service, monitor machine vulnerabilities and provide fix functions. License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} @@ -8,6 +8,8 @@ Source0: %{name}-%{version}.tar.gz Patch0001: cveinfo_api_add_host_id_not_exists_tip.patch Patch0002: param_length_validate.patch Patch0003: fix_host_repo_filter_query_failed.patch +Patch0004: 0001-avoid-500-errors-by-uwsgi.patch + BuildRequires: python3-setuptools Requires: aops-vulcanus >= %{version}-%{release} @@ -42,6 +44,10 @@ Cve management service, monitor machine vulnerabilities and provide fix function %changelog +* Mon Dec 05 2022 gongzhengtang - v1.1.1-3 +- Avoid the occasional 500 or query error when the api +- service is started through uwsgi + * Fri Dec 02 2022 gongzhengtang - v1.1.1-2 - fix param length validate and other bugs