mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
🐛 Fix db connection check /healthz (#2041)
* 🐛 fix db connection check
* 👕 fix missing semi
* ⏪ Revert "🐛 Hardcode typeorm@0.2.34 as new version makes health-check fail"
This reverts commit ddee2ec47c
.
* 🐛 fix health-check in WebhookServer
This commit is contained in:
parent
72d57537de
commit
ffecbc7004
|
@ -120,7 +120,7 @@
|
||||||
"sqlite3": "^5.0.1",
|
"sqlite3": "^5.0.1",
|
||||||
"sse-channel": "^3.1.1",
|
"sse-channel": "^3.1.1",
|
||||||
"tslib": "1.14.1",
|
"tslib": "1.14.1",
|
||||||
"typeorm": "0.2.34",
|
"typeorm": "^0.2.30",
|
||||||
"winston": "^3.3.3"
|
"winston": "^3.3.3"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
|
|
|
@ -466,16 +466,18 @@ class App {
|
||||||
// Does very basic health check
|
// Does very basic health check
|
||||||
this.app.get('/healthz', async (req: express.Request, res: express.Response) => {
|
this.app.get('/healthz', async (req: express.Request, res: express.Response) => {
|
||||||
|
|
||||||
const connectionManager = getConnectionManager();
|
const connection = getConnectionManager().get();
|
||||||
|
|
||||||
if (connectionManager.connections.length === 0) {
|
try {
|
||||||
const error = new ResponseHelper.ResponseError('No Database connection found!', undefined, 503);
|
if (connection.isConnected === false) {
|
||||||
return ResponseHelper.sendErrorResponse(res, error);
|
// Connection is not active
|
||||||
}
|
throw new Error('No active database connection!');
|
||||||
|
}
|
||||||
if (connectionManager.connections[0].isConnected === false) {
|
// DB ping
|
||||||
// Connection is not active
|
await connection.query('SELECT 1');
|
||||||
const error = new ResponseHelper.ResponseError('Database connection not active!', undefined, 503);
|
} catch (err) {
|
||||||
|
LoggerProxy.error('No Database connection!', err);
|
||||||
|
const error = new ResponseHelper.ResponseError('No Database connection!', undefined, 503);
|
||||||
return ResponseHelper.sendErrorResponse(res, error);
|
return ResponseHelper.sendErrorResponse(res, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,16 +248,17 @@ class App {
|
||||||
// Does very basic health check
|
// Does very basic health check
|
||||||
this.app.get('/healthz', async (req: express.Request, res: express.Response) => {
|
this.app.get('/healthz', async (req: express.Request, res: express.Response) => {
|
||||||
|
|
||||||
const connectionManager = getConnectionManager();
|
const connection = getConnectionManager().get();
|
||||||
|
|
||||||
if (connectionManager.connections.length === 0) {
|
try {
|
||||||
const error = new ResponseHelper.ResponseError('No Database connection found!', undefined, 503);
|
if (connection.isConnected === false) {
|
||||||
return ResponseHelper.sendErrorResponse(res, error);
|
// Connection is not active
|
||||||
}
|
throw new Error('No active database connection!');
|
||||||
|
}
|
||||||
if (connectionManager.connections[0].isConnected === false) {
|
// DB ping
|
||||||
// Connection is not active
|
await connection.query('SELECT 1');
|
||||||
const error = new ResponseHelper.ResponseError('Database connection not active!', undefined, 503);
|
} catch (err) {
|
||||||
|
const error = new ResponseHelper.ResponseError('No Database connection!', undefined, 503);
|
||||||
return ResponseHelper.sendErrorResponse(res, error);
|
return ResponseHelper.sendErrorResponse(res, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue