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

Chore: Improve service's licence check #27872

Merged
merged 3 commits into from Jan 30, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 12 additions & 7 deletions apps/meteor/ee/server/lib/EnterpriseCheck.ts
Expand Up @@ -18,7 +18,7 @@ export const EnterpriseCheck: ServiceSchema = {
const services: {
name: string;
nodes: string[];
}[] = await this.broker.call('$node.services');
}[] = await this.broker.call('$node.services', { skipInternal: true });

const currentService = services.find((service) => {
return service.name === this.name;
Expand All @@ -33,16 +33,21 @@ export const EnterpriseCheck: ServiceSchema = {

const firstNode = nodes.sort().shift();

// if the first node is the current node and there are others nodes running the same service, then it should shutdown
return firstNode === this.broker.nodeID && nodes.length > 0;
// if the first node is the current node and there are others nodes running the same service or
// if this is the only one node online, then we should shutdown
return firstNode === this.broker.nodeID && (nodes.length > 0 || services.length === 1);
},
},
async started(): Promise<void> {
setInterval(async () => {
const hasLicense = await this.broker.call('license.hasLicense', ['scalability']);
if (hasLicense) {
checkFails = 0;
return;
try {
const hasLicense = await this.broker.call('license.hasLicense', ['scalability']);
if (hasLicense) {
checkFails = 0;
return;
}
} catch (e: unknown) {
// check failed, so continue
}

if (++checkFails < maxFails) {
Expand Down