!15 规避通过uwsgi启动api服务时偶现500或查询报错问题
From: @gongzt Reviewed-by: @Lostwayzxc Signed-off-by: @Lostwayzxc
This commit is contained in:
commit
0f48a0fa22
98
0001-avoid-500-errors-by-uwsgi.patch
Normal file
98
0001-avoid-500-errors-by-uwsgi.patch
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
From 53fa9132c94060f0f9a0285dd813af7805b28718 Mon Sep 17 00:00:00 2001
|
||||||
|
From: gongzt <gong_zhengtang@163.com>
|
||||||
|
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
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: aops-apollo
|
Name: aops-apollo
|
||||||
Version: v1.1.1
|
Version: v1.1.1
|
||||||
Release: 2
|
Release: 3
|
||||||
Summary: Cve management service, monitor machine vulnerabilities and provide fix functions.
|
Summary: Cve management service, monitor machine vulnerabilities and provide fix functions.
|
||||||
License: MulanPSL2
|
License: MulanPSL2
|
||||||
URL: https://gitee.com/openeuler/%{name}
|
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
|
Patch0001: cveinfo_api_add_host_id_not_exists_tip.patch
|
||||||
Patch0002: param_length_validate.patch
|
Patch0002: param_length_validate.patch
|
||||||
Patch0003: fix_host_repo_filter_query_failed.patch
|
Patch0003: fix_host_repo_filter_query_failed.patch
|
||||||
|
Patch0004: 0001-avoid-500-errors-by-uwsgi.patch
|
||||||
|
|
||||||
|
|
||||||
BuildRequires: python3-setuptools
|
BuildRequires: python3-setuptools
|
||||||
Requires: aops-vulcanus >= %{version}-%{release}
|
Requires: aops-vulcanus >= %{version}-%{release}
|
||||||
@ -42,6 +44,10 @@ Cve management service, monitor machine vulnerabilities and provide fix function
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Dec 05 2022 gongzhengtang<gong_zhengtang@163.com> - v1.1.1-3
|
||||||
|
- Avoid the occasional 500 or query error when the api
|
||||||
|
- service is started through uwsgi
|
||||||
|
|
||||||
* Fri Dec 02 2022 gongzhengtang<gong_zhengtang@163.com> - v1.1.1-2
|
* Fri Dec 02 2022 gongzhengtang<gong_zhengtang@163.com> - v1.1.1-2
|
||||||
- fix param length validate and other bugs
|
- fix param length validate and other bugs
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user