feat(core): Add unique id to instances (#6863)

* add serverId and workerId

* adjust id format

* fix logger init / test

* update implementation
This commit is contained in:
Michael Auerswald
2023-08-07 17:03:21 +02:00
committed by GitHub
parent f038e1e9a6
commit 6499f42481
8 changed files with 35 additions and 3 deletions

View File

@@ -23,6 +23,9 @@ import { N8N_VERSION } from '@/constants';
import { BaseCommand } from './BaseCommand';
import { ExecutionRepository } from '@db/repositories';
import { OwnershipService } from '@/services/ownership.service';
import { generateHostInstanceId } from '@/databases/utils/generators';
// eslint-disable-next-line import/no-extraneous-dependencies
import { IConfig } from '@oclif/config';
export class Worker extends BaseCommand {
static description = '\nStarts a n8n worker';
@@ -43,6 +46,13 @@ export class Worker extends BaseCommand {
static jobQueue: JobQueue;
readonly uniqueInstanceId: string;
constructor(argv: string[], cmdConfig: IConfig) {
super(argv, cmdConfig);
this.uniqueInstanceId = generateHostInstanceId('worker');
}
/**
* Stop n8n in a graceful way.
* Make for example sure that all the webhooks from third party services
@@ -227,6 +237,7 @@ export class Worker extends BaseCommand {
async init() {
await this.initCrashJournal();
await super.init();
this.logger.debug(`Worker ID: ${this.uniqueInstanceId}`);
this.logger.debug('Starting n8n worker...');
await this.initLicense();