diff --git a/packages/@n8n/config/src/configs/generic.config.ts b/packages/@n8n/config/src/configs/generic.config.ts new file mode 100644 index 0000000000..f6960b2415 --- /dev/null +++ b/packages/@n8n/config/src/configs/generic.config.ts @@ -0,0 +1,15 @@ +import { Config, Env } from '../decorators'; + +@Config +export class GenericConfig { + /** Default timezone for the n8n instance. Can be overridden on a per-workflow basis. */ + @Env('GENERIC_TIMEZONE') + timezone: string = 'America/New_York'; + + @Env('N8N_RELEASE_TYPE') + releaseChannel: 'stable' | 'beta' | 'nightly' | 'dev' = 'dev'; + + /** Grace period (in seconds) to wait for components to shut down before process exit. */ + @Env('N8N_GRACEFUL_SHUTDOWN_TIMEOUT') + gracefulShutdownTimeout: number = 30; +} diff --git a/packages/@n8n/config/src/index.ts b/packages/@n8n/config/src/index.ts index 9682160f3c..b76e5c455c 100644 --- a/packages/@n8n/config/src/index.ts +++ b/packages/@n8n/config/src/index.ts @@ -5,6 +5,7 @@ import { EndpointsConfig } from './configs/endpoints.config'; import { EventBusConfig } from './configs/event-bus.config'; import { ExternalSecretsConfig } from './configs/external-secrets.config'; import { ExternalStorageConfig } from './configs/external-storage.config'; +import { GenericConfig } from './configs/generic.config'; import { LoggingConfig } from './configs/logging.config'; import { MultiMainSetupConfig } from './configs/multi-main-setup.config'; import { NodesConfig } from './configs/nodes.config'; @@ -97,4 +98,7 @@ export class GlobalConfig { @Nested multiMainSetup: MultiMainSetupConfig; + + @Nested + generic: GenericConfig; } diff --git a/packages/@n8n/config/test/config.test.ts b/packages/@n8n/config/test/config.test.ts index 79d27c9434..af40e7a8e1 100644 --- a/packages/@n8n/config/test/config.test.ts +++ b/packages/@n8n/config/test/config.test.ts @@ -250,6 +250,11 @@ describe('GlobalConfig', () => { ttl: 10, interval: 3, }, + generic: { + timezone: 'America/New_York', + releaseChannel: 'dev', + gracefulShutdownTimeout: 30, + }, }; it('should use all default values when no env variables are defined', () => { diff --git a/packages/cli/src/commands/base-command.ts b/packages/cli/src/commands/base-command.ts index 303b3cae3e..64ce401257 100644 --- a/packages/cli/src/commands/base-command.ts +++ b/packages/cli/src/commands/base-command.ts @@ -55,7 +55,8 @@ export abstract class BaseCommand extends Command { /** * How long to wait for graceful shutdown before force killing the process. */ - protected gracefulShutdownTimeoutInS = config.getEnv('generic.gracefulShutdownTimeout'); + protected gracefulShutdownTimeoutInS = + Container.get(GlobalConfig).generic.gracefulShutdownTimeout; /** Whether to init community packages (if enabled) */ protected needsCommunityPackages = false; diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts index 0c799aa8a5..c9e34355ba 100644 --- a/packages/cli/src/config/index.ts +++ b/packages/cli/src/config/index.ts @@ -122,7 +122,7 @@ if (executionProcess === 'own') { } setGlobalState({ - defaultTimezone: config.getEnv('generic.timezone'), + defaultTimezone: Container.get(GlobalConfig).generic.timezone, }); // eslint-disable-next-line import/no-default-export diff --git a/packages/cli/src/config/schema.ts b/packages/cli/src/config/schema.ts index 31b11658e2..e0e322210e 100644 --- a/packages/cli/src/config/schema.ts +++ b/packages/cli/src/config/schema.ts @@ -162,33 +162,6 @@ export const schema = { }, }, - generic: { - // The timezone to use. Is important for nodes like "Cron" which start the - // workflow automatically at a specified time. This setting can also be - // overwritten on a per workflow basis in the workflow settings in the - // editor. - timezone: { - doc: 'The timezone to use', - format: '*', - default: 'America/New_York', - env: 'GENERIC_TIMEZONE', - }, - - releaseChannel: { - doc: 'N8N release channel', - format: ['stable', 'beta', 'nightly', 'dev'] as const, - 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', - }, - }, - secure_cookie: { doc: 'This sets the `Secure` flag on n8n auth cookie', format: Boolean, diff --git a/packages/cli/src/services/frontend.service.ts b/packages/cli/src/services/frontend.service.ts index a83158e96e..ef3ed5a5f9 100644 --- a/packages/cli/src/services/frontend.service.ts +++ b/packages/cli/src/services/frontend.service.ts @@ -96,7 +96,7 @@ export class FrontendService { executionTimeout: config.getEnv('executions.timeout'), maxExecutionTimeout: config.getEnv('executions.maxTimeout'), workflowCallerPolicyDefaultOption: this.globalConfig.workflows.callerPolicyDefaultOption, - timezone: config.getEnv('generic.timezone'), + timezone: this.globalConfig.generic.timezone, urlBaseWebhook: this.urlService.getWebhookBaseUrl(), urlBaseEditor: instanceBaseUrl, binaryDataMode: config.getEnv('binaryDataManager.mode'), @@ -106,7 +106,7 @@ export class FrontendService { authCookie: { secure: config.getEnv('secure_cookie'), }, - releaseChannel: config.getEnv('generic.releaseChannel'), + releaseChannel: this.globalConfig.generic.releaseChannel, oauthCallbackUrls: { oauth1: `${instanceBaseUrl}/${restEndpoint}/oauth1-credential/callback`, oauth2: `${instanceBaseUrl}/${restEndpoint}/oauth2-credential/callback`,