server: add worker ids

This commit is contained in:
Koushik Dutta
2024-11-16 11:35:39 -08:00
parent 0bf0ec08ab
commit 977666bc3c
2 changed files with 6 additions and 2 deletions

View File

@@ -96,7 +96,7 @@
"env": {
"SCRYPTED_CLUSTER_LABELS": "compute",
"SCRYPTED_CLUSTER_MODE": "client",
"SCRYPTED_CLUSTER_SERVER": "192.168.2.124",
"SCRYPTED_CLUSTER_SERVER": "scrypted-nvr",
"SCRYPTED_CLUSTER_SECRET": "swordfish",
"SCRYPTED_CAN_RESTART": "true",
"SCRYPTED_VOLUME": "/Users/koush/.scrypted-cluster/volume-client",

View File

@@ -1,3 +1,4 @@
import os from 'os';
import type { ForkOptions } from '@scrypted/types';
import { once } from 'events';
import net from 'net';
@@ -155,7 +156,7 @@ export function startClusterClient(mainFilename: string) {
const auth: ClusterObject = {
address: socket.localAddress,
port: socket.localPort,
id: undefined,
id: process.env.SCRYPTED_CLUSTER_ID || os.hostname(),
proxyId: undefined,
sourceKey: undefined,
sha256: undefined,
@@ -285,6 +286,9 @@ export function createClusterServer(runtime: ScryptedRuntime, certificate: Retur
const sha256 = computeClusterObjectHash(auth, runtime.clusterSecret);
if (sha256 !== auth.sha256)
throw new Error('cluster object hash mismatch');
peer.peerName = auth.id || `${socket.remoteAddress}`;
// the remote address may be ipv6 prefixed so use a fuzzy match.
// eg ::ffff:192.168.2.124
if (!process.env.SCRYPTED_DISABLE_CLUSTER_SERVER_TRUST) {