Skip to content

Commit

Permalink
fix(cluster): use instance name as node id
Browse files Browse the repository at this point in the history
The IDs used to be generated on each restart, which leads to confusing
logs and wrong removal behavior. The instance name should be unique
anyway, so we might as well use it for the clustering.
  • Loading branch information
mKeRix committed Feb 17, 2020
1 parent 56cfe34 commit e028414
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cluster/cluster.service.ts
Expand Up @@ -12,6 +12,7 @@ import * as os from 'os';
import { NetworkInterfaceInfo } from 'os';
import { ConfigService } from '../config/config.service';
import { ClusterConfig } from './cluster.config';
import { makeId } from '../util/id';

let mdns;
try {
Expand All @@ -33,6 +34,7 @@ export class ClusterService extends Democracy

constructor(configService: ConfigService) {
const config = configService.get('cluster');
const globalConfig = configService.get('global');

const networkInterfaces = _.flatMap<NetworkInterfaceInfo>(
config.networkInterface
Expand All @@ -43,6 +45,7 @@ export class ClusterService extends Democracy
address => address.internal === false && address.family === 'IPv4'
).address;
super({
id: makeId(globalConfig.instanceName),
source: `${ip}:${config.port}`,
peers: Array.from(config.peerAddresses),
timeout: config.timeout * 1000,
Expand Down

0 comments on commit e028414

Please sign in to comment.