-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): Lock
webhook
process out of multi-main setup (no-ch…
…angelog) (#8549)
- release/1.37.2
- n8n@1.73.1
- n8n@1.73.0
- n8n@1.72.1
- n8n@1.72.0
- n8n@1.71.3
- n8n@1.71.2
- n8n@1.71.1
- n8n@1.71.0
- n8n@1.70.4
- n8n@1.70.3
- n8n@1.70.2
- n8n@1.70.1
- n8n@1.70.0
- n8n@1.69.2
- n8n@1.69.1
- n8n@1.69.0
- n8n@1.68.1
- n8n@1.68.0
- n8n@1.67.1
- n8n@1.67.0
- n8n@1.66.0
- n8n@1.65.2
- n8n@1.65.1
- n8n@1.65.0
- n8n@1.64.3
- n8n@1.64.2
- n8n@1.64.1
- n8n@1.64.0
- n8n@1.63.4
- n8n@1.63.3
- n8n@1.63.2
- n8n@1.63.1
- n8n@1.63.0
- n8n@1.62.6
- n8n@1.62.5
- n8n@1.62.4
- n8n@1.62.3
- n8n@1.62.2
- n8n@1.62.1
- n8n@1.61.0
- n8n@1.60.1
- n8n@1.60.0
- n8n@1.59.4
- n8n@1.59.3
- n8n@1.59.2
- n8n@1.59.1
- n8n@1.59.0
- n8n@1.58.2
- n8n@1.58.1
- n8n@1.58.0
- n8n@1.57.0
- n8n@1.56.2
- n8n@1.56.1
- n8n@1.56.0
- n8n@1.55.3
- n8n@1.55.2
- n8n@1.55.1
- n8n@1.55.0
- n8n@1.54.4
- n8n@1.54.3
- n8n@1.54.2
- n8n@1.54.1
- n8n@1.54.0
- n8n@1.53.2
- n8n@1.53.1
- n8n@1.53.0
- n8n@1.52.2
- n8n@1.52.1
- n8n@1.52.0
- n8n@1.51.2
- n8n@1.51.1
- n8n@1.51.0
- n8n@1.50.2
- n8n@1.50.1
- n8n@1.50.0
- n8n@1.49.0
- n8n@1.48.3
- n8n@1.48.2
- n8n@1.48.1
- n8n@1.48.0
- n8n@1.47.3
- n8n@1.47.2
- n8n@1.47.1
- n8n@1.47.0
- n8n@1.46.0
- n8n@1.45.2
- n8n@1.45.1
- n8n@1.45.0
- n8n@1.44.2
- n8n@1.44.1
- n8n@1.44.0
- n8n@1.43.1
- n8n@1.43.0
- n8n@1.42.2
- n8n@1.42.1
- n8n@1.42.0
- n8n@1.41.1
- n8n@1.41.0
- n8n@1.40.0
- n8n@1.39.1
- n8n@1.39.0
- n8n@1.38.2
- n8n@1.38.1
- n8n@1.38.0
- n8n@1.37.4
- n8n@1.37.3
- n8n@1.37.2
- n8n@1.37.1
- n8n@1.37.0
- n8n@1.36.4
- n8n@1.36.3
- n8n@1.36.2
- n8n@1.36.1
- n8n@1.36.0
- n8n@1.35.0
- n8n@1.34.2
- n8n@1.34.1
- n8n@1.34.0
- n8n@1.33.1
- n8n@1.33.0
- n8n@1.32.2
- n8n@1.32.1
- n8n@1.32.0
- n8n@1.31.2
- n8n@1.31.1
- n8n@1.31.0
- n8n@1.30.1
- n8n@1.30.0
- n8n@1.29.1
- n8n@1.29.0
- n8n@1.28.0
Showing
2 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 72 additions & 3 deletions
75
packages/cli/src/services/orchestration/webhook/handleCommandMessageWebhook.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,75 @@ | ||
import { handleCommandMessageMain } from '../main/handleCommandMessageMain'; | ||
import { ExternalSecretsManager } from '@/ExternalSecrets/ExternalSecretsManager.ee'; | ||
import { License } from '@/License'; | ||
import { MessageEventBus } from '@/eventbus'; | ||
import Container from 'typedi'; | ||
import { Logger } from 'winston'; | ||
import { messageToRedisServiceCommandObject, debounceMessageReceiver } from '../helpers'; | ||
import config from '@/config'; | ||
|
||
export async function handleCommandMessageWebhook(messageString: string) { | ||
// currently webhooks handle commands the same way as the main instance | ||
return await handleCommandMessageMain(messageString); | ||
const queueModeId = config.getEnv('redis.queueModeId'); | ||
const isMainInstance = config.getEnv('generic.instanceType') === 'main'; | ||
const message = messageToRedisServiceCommandObject(messageString); | ||
const logger = Container.get(Logger); | ||
|
||
if (message) { | ||
logger.debug( | ||
`RedisCommandHandler(main): Received command message ${message.command} from ${message.senderId}`, | ||
); | ||
|
||
if ( | ||
message.senderId === queueModeId || | ||
(message.targets && !message.targets.includes(queueModeId)) | ||
) { | ||
// Skipping command message because it's not for this instance | ||
logger.debug( | ||
`Skipping command message ${message.command} because it's not for this instance.`, | ||
); | ||
return message; | ||
} | ||
|
||
switch (message.command) { | ||
case 'reloadLicense': | ||
if (!debounceMessageReceiver(message, 500)) { | ||
message.payload = { | ||
result: 'debounced', | ||
}; | ||
return message; | ||
} | ||
|
||
if (isMainInstance && !config.getEnv('multiMainSetup.enabled')) { | ||
// at this point in time, only a single main instance is supported, thus this command _should_ never be caught currently | ||
logger.error( | ||
'Received command to reload license via Redis, but this should not have happened and is not supported on the main instance yet.', | ||
); | ||
return message; | ||
} | ||
await Container.get(License).reload(); | ||
break; | ||
case 'restartEventBus': | ||
if (!debounceMessageReceiver(message, 200)) { | ||
message.payload = { | ||
result: 'debounced', | ||
}; | ||
return message; | ||
} | ||
await Container.get(MessageEventBus).restart(); | ||
case 'reloadExternalSecretsProviders': | ||
if (!debounceMessageReceiver(message, 200)) { | ||
message.payload = { | ||
result: 'debounced', | ||
}; | ||
return message; | ||
} | ||
await Container.get(ExternalSecretsManager).reloadAllProviders(); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
|
||
return message; | ||
} | ||
|
||
return; | ||
} |