mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
feat(core): Improve health check (#6205)
* remove unnecesary Db re-initialization this is from before we added `Db.init` in `WorkflowRunnerProcess` * feat(core): Improved health check * make health check not care about DB connections * close DB connections, and shutdown the timer
This commit is contained in:
committed by
GitHub
parent
e3f47994b1
commit
9e7b9fb443
@@ -5,6 +5,7 @@ import type { INodeTypes } from 'n8n-workflow';
|
||||
import { LoggerProxy, ErrorReporterProxy as ErrorReporter, sleep } from 'n8n-workflow';
|
||||
import type { IUserSettings } from 'n8n-core';
|
||||
import { BinaryDataManager, UserSettings } from 'n8n-core';
|
||||
import type { AbstractServer } from '@/AbstractServer';
|
||||
import { getLogger } from '@/Logger';
|
||||
import config from '@/config';
|
||||
import * as Db from '@/Db';
|
||||
@@ -36,6 +37,8 @@ export abstract class BaseCommand extends Command {
|
||||
|
||||
protected instanceId: string;
|
||||
|
||||
protected server?: AbstractServer;
|
||||
|
||||
async init(): Promise<void> {
|
||||
await initErrorHandling();
|
||||
|
||||
@@ -55,6 +58,12 @@ export abstract class BaseCommand extends Command {
|
||||
this.exitWithCrash('There was an error initializing DB', error),
|
||||
);
|
||||
|
||||
await this.server?.init();
|
||||
|
||||
await Db.migrate().catch(async (error: Error) =>
|
||||
this.exitWithCrash('There was an error running database migrations', error),
|
||||
);
|
||||
|
||||
if (process.env.WEBHOOK_TUNNEL_URL) {
|
||||
LoggerProxy.warn(
|
||||
'You are still using the WEBHOOK_TUNNEL_URL environment variable. It has been deprecated and will be removed in a future version of n8n. Please switch to using WEBHOOK_URL instead.',
|
||||
@@ -112,9 +121,9 @@ export abstract class BaseCommand extends Command {
|
||||
|
||||
async finally(error: Error | undefined) {
|
||||
if (inTest || this.id === 'start') return;
|
||||
if (Db.isInitialized) {
|
||||
if (Db.connectionState.connected) {
|
||||
await sleep(100); // give any in-flight query some time to finish
|
||||
await Db.getConnection().destroy();
|
||||
await Db.close();
|
||||
}
|
||||
const exitCode = error instanceof ExitError ? error.oclif.exit : error ? 1 : 0;
|
||||
this.exit(exitCode);
|
||||
|
||||
Reference in New Issue
Block a user