feat(core): Add N8N_GRACEFUL_SHUTDOWN_TIMEOUT env var (#8068)

Add generic N8N_GRACEFUL_SHUTDOWN_TIMEOUT which controls how long n8n
process will wait for graceful exit before exitting forcefully. This
variables replaces the QUEUE_WORKER_TIMEOUT variable that was used for
worker process.

DEPRECATED: QUEUE_WORKER_TIMEOUT deprected

QUEUE_WORKER_TIMEOUT environment variable has been replaced with
N8N_GRACEFUL_SHUTDOWN_TIMEOUT.
This commit is contained in:
Tomi Turtiainen 2023-12-18 14:04:19 +02:00 committed by GitHub
parent 0590ac7826
commit 614f488386
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View file

@ -42,9 +42,8 @@ export abstract class BaseCommand extends Command {
/** /**
* How long to wait for graceful shutdown before force killing the process. * How long to wait for graceful shutdown before force killing the process.
* Subclasses can override this value.
*/ */
protected gracefulShutdownTimeoutInS: number = 30; protected gracefulShutdownTimeoutInS: number = config.getEnv('generic.gracefulShutdownTimeout');
async init(): Promise<void> { async init(): Promise<void> {
await initErrorHandling(); await initErrorHandling();

View file

@ -264,7 +264,13 @@ export class Worker extends BaseCommand {
} }
async init() { async init() {
this.gracefulShutdownTimeoutInS = config.getEnv('queue.bull.gracefulShutdownTimeout'); const configuredShutdownTimeout = config.getEnv('queue.bull.gracefulShutdownTimeout');
if (configuredShutdownTimeout) {
this.gracefulShutdownTimeoutInS = configuredShutdownTimeout;
this.logger.warn(
'QUEUE_WORKER_TIMEOUT has been deprecated. Rename it to N8N_GRACEFUL_SHUTDOWN_TIMEOUT.',
);
}
await this.initCrashJournal(); await this.initCrashJournal();
this.logger.debug('Starting n8n worker...'); this.logger.debug('Starting n8n worker...');

View file

@ -439,7 +439,7 @@ export const schema = {
env: 'QUEUE_RECOVERY_INTERVAL', env: 'QUEUE_RECOVERY_INTERVAL',
}, },
gracefulShutdownTimeout: { gracefulShutdownTimeout: {
doc: 'How long should n8n wait for running executions before exiting worker process (seconds)', doc: '[DEPRECATED] (Use N8N_GRACEFUL_SHUTDOWN_TIMEOUT instead) How long should n8n wait for running executions before exiting worker process (seconds)',
format: Number, format: Number,
default: 30, default: 30,
env: 'QUEUE_WORKER_TIMEOUT', env: 'QUEUE_WORKER_TIMEOUT',
@ -497,6 +497,13 @@ export const schema = {
default: 'dev', default: 'dev',
env: 'N8N_RELEASE_TYPE', env: 'N8N_RELEASE_TYPE',
}, },
gracefulShutdownTimeout: {
doc: 'How long should n8n process wait for components to shut down before exiting the process (seconds)',
format: Number,
default: 30,
env: 'N8N_GRACEFUL_SHUTDOWN_TIMEOUT',
},
}, },
// How n8n can be reached (Editor & REST-API) // How n8n can be reached (Editor & REST-API)