Files
n8n-enterprise-unlocked/packages/cli/src/services/redis/RedisServiceCommands.ts
Michael Auerswald 9f797b96d8 feat(core): Add command to trigger license refresh on workers (#7184)
This PR implements the updated license SDK so that worker and webhook
instances do not auto-renew licenses any more.

Instead, they receive a `reloadLicense` command via the Redis client
that will fetch the updated license after it was saved on the main
instance

This also contains some refactoring with moving redis sub and pub
clients into the event bus directly, to prevent cyclic dependency
issues.
2023-09-17 11:05:54 +02:00

60 lines
1.3 KiB
TypeScript

export type RedisServiceCommand =
| 'getStatus'
| 'getId'
| 'restartEventBus'
| 'stopWorker'
| 'reloadLicense';
/**
* An object to be sent via Redis pub/sub from the main process to the workers.
* @field command: The command to be executed.
* @field targets: The targets to execute the command on. Leave empty to execute on all workers or specify worker ids.
* @field payload: Optional arguments to be sent with the command.
*/
type RedisServiceBaseCommand = {
senderId?: string;
command: RedisServiceCommand;
payload?: {
[key: string]: string | number | boolean | string[] | number[] | boolean[];
};
};
export type RedisServiceWorkerResponseObject = {
workerId: string;
} & (
| RedisServiceBaseCommand
| {
command: 'getStatus';
payload: {
workerId: string;
runningJobs: string[];
freeMem: number;
totalMem: number;
uptime: number;
loadAvg: number[];
cpus: string[];
arch: string;
platform: NodeJS.Platform;
hostname: string;
net: string[];
};
}
| {
command: 'getId';
}
| {
command: 'restartEventBus';
payload: {
result: 'success' | 'error';
error?: string;
};
}
| {
command: 'stopWorker';
}
);
export type RedisServiceCommandObject = {
targets?: string[];
} & RedisServiceBaseCommand;