Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Add N8N_GRACEFUL_SHUTDOWN_TIMEOUT env var #8068

Merged
merged 2 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/cli/src/commands/BaseCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ export abstract class BaseCommand extends Command {

/**
* 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> {
await initErrorHandling();
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/commands/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,13 @@ export class Worker extends BaseCommand {
}

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();

this.logger.debug('Starting n8n worker...');
Expand Down
9 changes: 8 additions & 1 deletion packages/cli/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ export const schema = {
env: 'QUEUE_RECOVERY_INTERVAL',
},
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)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update the docs as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format: Number,
default: 30,
env: 'QUEUE_WORKER_TIMEOUT',
Expand Down Expand Up @@ -497,6 +497,13 @@ export const schema = {
default: 'dev',
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)
Expand Down
Loading