mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 02:08:36 +00:00
Merge pull request #104 from camptocamp/revert-99-11.0-monitoring_check_db_connection
Revert "[11.0] [IMP] monitoring_status: check the db is reachable"
This commit is contained in:
@@ -5,12 +5,9 @@
|
|||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import psycopg2
|
|
||||||
|
|
||||||
import werkzeug
|
import werkzeug
|
||||||
|
|
||||||
from odoo import http
|
from odoo import http
|
||||||
from odoo.http import request
|
|
||||||
from odoo.addons.web.controllers.main import ensure_db
|
from odoo.addons.web.controllers.main import ensure_db
|
||||||
|
|
||||||
|
|
||||||
@@ -34,24 +31,10 @@ class Monitoring(http.Controller):
|
|||||||
@http.route('/monitoring/status', type='http', auth='none')
|
@http.route('/monitoring/status', type='http', auth='none')
|
||||||
def status(self):
|
def status(self):
|
||||||
ensure_db()
|
ensure_db()
|
||||||
http_status = 200
|
|
||||||
# TODO: add 'sub-systems' status and infos:
|
# TODO: add 'sub-systems' status and infos:
|
||||||
# queue job, cron, database, ...
|
# queue job, cron, database, ...
|
||||||
headers = {'Content-Type': 'application/json'}
|
headers = {'Content-Type': 'application/json'}
|
||||||
info = {'status': 1}
|
info = {'status': 1}
|
||||||
# check the database connection
|
|
||||||
try:
|
|
||||||
cr = request.env.cr
|
|
||||||
cr.execute(
|
|
||||||
'SELECT value '
|
|
||||||
'FROM ir_config_parameter '
|
|
||||||
'WHERE key=%s',
|
|
||||||
('web.base.url',))
|
|
||||||
result = cr.fetchone()
|
|
||||||
info['web.base.url'] = result or ''
|
|
||||||
except psycopg2.OperationalError as exc:
|
|
||||||
info['database_error'] = str(exc)
|
|
||||||
http_status = 503
|
|
||||||
session = http.request.session
|
session = http.request.session
|
||||||
# We set a custom expiration of 1 second for this request, as we do a
|
# We set a custom expiration of 1 second for this request, as we do a
|
||||||
# lot of health checks, we don't want those anonymous sessions to be
|
# lot of health checks, we don't want those anonymous sessions to be
|
||||||
@@ -61,6 +44,4 @@ class Monitoring(http.Controller):
|
|||||||
# Redis.
|
# Redis.
|
||||||
if not session.uid:
|
if not session.uid:
|
||||||
session.expiration = 1
|
session.expiration = 1
|
||||||
return werkzeug.wrappers.Response(
|
return werkzeug.wrappers.Response(json.dumps(info), headers=headers)
|
||||||
json.dumps(info), status=http_status, headers=headers
|
|
||||||
)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user