@scrypted/server 0.148.8 → 0.148.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cluster/cluster-setup.d.ts +0 -1
- package/dist/cluster/cluster-setup.js +0 -16
- package/dist/cluster/cluster-setup.js.map +1 -1
- package/dist/plugin/media.d.ts +3 -5
- package/dist/plugin/media.js +7 -50
- package/dist/plugin/media.js.map +1 -1
- package/dist/plugin/mediaobject.d.ts +1 -2
- package/dist/plugin/mediaobject.js +3 -9
- package/dist/plugin/mediaobject.js.map +1 -1
- package/dist/plugin/plugin-host.js +12 -4
- package/dist/plugin/plugin-host.js.map +1 -1
- package/dist/plugin/plugin-remote-worker.js +1 -2
- package/dist/plugin/plugin-remote-worker.js.map +1 -1
- package/dist/rpc.js +3 -2
- package/dist/rpc.js.map +1 -1
- package/dist/runtime.d.ts +0 -19
- package/dist/runtime.js +0 -10
- package/dist/runtime.js.map +1 -1
- package/package.json +2 -2
- package/python/cluster_setup.py +0 -1
- package/python/plugin_remote.py +0 -1
- package/src/cluster/cluster-setup.ts +0 -19
- package/src/plugin/media.ts +7 -61
- package/src/plugin/mediaobject.ts +3 -7
- package/src/plugin/plugin-host.ts +12 -5
- package/src/plugin/plugin-remote-worker.ts +1 -2
- package/src/rpc.ts +3 -2
- package/src/runtime.ts +1 -12
|
@@ -6,6 +6,7 @@ import os from 'os';
|
|
|
6
6
|
import { PassThrough } from 'stream';
|
|
7
7
|
import WebSocket from 'ws';
|
|
8
8
|
import { utilizesClusterForkWorker } from '../cluster/cluster-labels';
|
|
9
|
+
import { setupCluster } from '../cluster/cluster-setup';
|
|
9
10
|
import { Plugin, PluginDevice } from '../db-types';
|
|
10
11
|
import { IOServer, IOServerSocket } from '../io';
|
|
11
12
|
import type { LogEntry, Logger } from '../logger';
|
|
@@ -209,7 +210,7 @@ export class PluginHost {
|
|
|
209
210
|
|
|
210
211
|
const { runtime } = this.packageJson.scrypted;
|
|
211
212
|
const mediaManager = runtime && runtime !== 'node'
|
|
212
|
-
? new MediaManagerHostImpl(pluginDeviceId, () => scrypted.stateManager.getSystemState(), console, id => scrypted.getDevice(id), true
|
|
213
|
+
? new MediaManagerHostImpl(pluginDeviceId, () => scrypted.stateManager.getSystemState(), console, id => scrypted.getDevice(id), true)
|
|
213
214
|
: undefined;
|
|
214
215
|
|
|
215
216
|
this.api = new PluginHostAPI(scrypted, this.pluginId, this, mediaManager!);
|
|
@@ -373,7 +374,6 @@ export class PluginHost {
|
|
|
373
374
|
reject(new Error('peer disconnected'));
|
|
374
375
|
}
|
|
375
376
|
});
|
|
376
|
-
this.scrypted.clusterSetup.registerClusterPeer(this.peer);
|
|
377
377
|
|
|
378
378
|
peer = Promise.resolve(this.peer);
|
|
379
379
|
|
|
@@ -400,12 +400,20 @@ export class PluginHost {
|
|
|
400
400
|
}
|
|
401
401
|
});
|
|
402
402
|
|
|
403
|
+
const clusterSetup = setupCluster(this.peer);
|
|
403
404
|
const { runtimeWorker, forkPeer, clusterWorkerId } = createClusterForkWorker(
|
|
404
405
|
runtimeWorkerOptions,
|
|
405
406
|
scrypted,
|
|
406
|
-
|
|
407
|
+
(async () => {
|
|
408
|
+
await clusterSetup.initializeCluster({
|
|
409
|
+
clusterId: this.scrypted.clusterId,
|
|
410
|
+
clusterSecret: this.scrypted.clusterSecret,
|
|
411
|
+
clusterWorkerId: this.scrypted.serverClusterWorkerId,
|
|
412
|
+
});
|
|
413
|
+
return this.scrypted.clusterFork;
|
|
414
|
+
})(),
|
|
407
415
|
async () => fs.promises.readFile(this.zipFile),
|
|
408
|
-
|
|
416
|
+
clusterSetup.connectRPCObject);
|
|
409
417
|
|
|
410
418
|
forkPeer.then(peer => {
|
|
411
419
|
const originalPeer = this.peer;
|
|
@@ -500,7 +508,6 @@ export class PluginHost {
|
|
|
500
508
|
console,
|
|
501
509
|
id => this.scrypted.getDevice(id),
|
|
502
510
|
!accessControls,
|
|
503
|
-
this.scrypted.clusterSetup.connectRPCObject,
|
|
504
511
|
);
|
|
505
512
|
const api = new PluginAPIProxy(this.api, mediaManager);
|
|
506
513
|
api.acl = accessControls;
|
|
@@ -45,7 +45,6 @@ export function startPluginRemote(mainFilename: string, pluginId: string, peerSe
|
|
|
45
45
|
const { initializeCluster, connectRPCObject, mainThreadBrokerRegister, mainThreadPort } = clusterPeerSetup;
|
|
46
46
|
|
|
47
47
|
peer.params.initializeCluster = initializeCluster;
|
|
48
|
-
peer.params.isRpcProxy = (value: any) => RpcPeer.isRpcProxy(value);
|
|
49
48
|
peer.params.ping = async (time: number) => {
|
|
50
49
|
return time;
|
|
51
50
|
};
|
|
@@ -79,7 +78,7 @@ export function startPluginRemote(mainFilename: string, pluginId: string, peerSe
|
|
|
79
78
|
createMediaManager: async (sm, dm) => {
|
|
80
79
|
systemManager = sm;
|
|
81
80
|
deviceManager = dm;
|
|
82
|
-
return new MediaManagerImpl(systemManager, dm
|
|
81
|
+
return new MediaManagerImpl(systemManager, dm);
|
|
83
82
|
},
|
|
84
83
|
onGetRemote: async (_api, _pluginId) => {
|
|
85
84
|
class PluginForkableAPI extends PluginAPIProxy {
|
package/src/rpc.ts
CHANGED
|
@@ -283,7 +283,8 @@ interface ErrorType {
|
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
export class RpcPeer {
|
|
286
|
-
|
|
286
|
+
// RPC param names come from the peer; only explicitly registered names should resolve.
|
|
287
|
+
params: { [name: string]: any } = Object.create(null);
|
|
287
288
|
pendingResults: { [id: string]: Deferred } = {};
|
|
288
289
|
localProxied = new Map<any, LocalProxiedEntry>();
|
|
289
290
|
localProxyMap = new Map<string, any>();
|
|
@@ -483,7 +484,7 @@ export class RpcPeer {
|
|
|
483
484
|
}
|
|
484
485
|
this.yieldedAsyncIterators.clear();
|
|
485
486
|
this.pendingResults = Object.freeze({});
|
|
486
|
-
this.params = Object.freeze(
|
|
487
|
+
this.params = Object.freeze(Object.create(null));
|
|
487
488
|
this.remoteWeakProxies = Object.freeze({});
|
|
488
489
|
this.localProxyMap.clear()
|
|
489
490
|
this.localProxied.clear();
|
package/src/runtime.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { Parser as TarParser } from 'tar';
|
|
|
15
15
|
import { URL } from "url";
|
|
16
16
|
import WebSocket, { Server as WebSocketServer } from "ws";
|
|
17
17
|
import { computeClusterObjectHash } from './cluster/cluster-hash';
|
|
18
|
-
import { isClusterAddress
|
|
18
|
+
import { isClusterAddress } from './cluster/cluster-setup';
|
|
19
19
|
import { ClusterObject } from './cluster/connect-rpc-object';
|
|
20
20
|
import { Plugin, PluginDevice, ScryptedAlert, ScryptedUser } from './db-types';
|
|
21
21
|
import { httpFetch } from './fetch/http-fetch';
|
|
@@ -47,7 +47,6 @@ import { getNpmPackageInfo, PluginComponent } from './services/plugin';
|
|
|
47
47
|
import { ServiceControl } from './services/service-control';
|
|
48
48
|
import { UsersService } from './services/users';
|
|
49
49
|
import { getState, ScryptedStateManager, setState } from './state';
|
|
50
|
-
import { RpcPeer } from './rpc';
|
|
51
50
|
|
|
52
51
|
interface DeviceProxyPair {
|
|
53
52
|
handler: PluginDeviceProxyHandler;
|
|
@@ -86,10 +85,6 @@ export class ScryptedRuntime extends PluginHttp<HttpPluginData> {
|
|
|
86
85
|
})
|
|
87
86
|
},
|
|
88
87
|
});
|
|
89
|
-
runtimePeer = new RpcPeer('runtime', 'runtime', (message, reject, serializationContext) => {
|
|
90
|
-
console.warn('unexpected message to runtime peer', message);
|
|
91
|
-
});
|
|
92
|
-
clusterSetup = setupCluster(this.runtimePeer);
|
|
93
88
|
pluginComponent = new PluginComponent(this);
|
|
94
89
|
serviceControl = new ServiceControl();
|
|
95
90
|
alerts = new Alerts(this);
|
|
@@ -949,12 +944,6 @@ export class ScryptedRuntime extends PluginHttp<HttpPluginData> {
|
|
|
949
944
|
// catch kill
|
|
950
945
|
process.on('SIGTERM', () => this.exit());
|
|
951
946
|
|
|
952
|
-
await this.clusterSetup.initializeCluster({
|
|
953
|
-
clusterId: this.clusterId,
|
|
954
|
-
clusterSecret: this.clusterSecret,
|
|
955
|
-
clusterWorkerId: this.serverClusterWorkerId,
|
|
956
|
-
});
|
|
957
|
-
|
|
958
947
|
for await (const pluginDevice of this.datastore.getAll(PluginDevice)) {
|
|
959
948
|
// this may happen due to race condition around deletion/update. investigate.
|
|
960
949
|
if (!pluginDevice.state) {
|