@scrypted/server 0.138.4 → 0.138.6
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/plugin/plugin-host-api.js +1 -1
- package/dist/plugin/plugin-host-api.js.map +1 -1
- package/dist/plugin/plugin-host.js +0 -4
- package/dist/plugin/plugin-host.js.map +1 -1
- package/dist/plugin/runtime/child-process-worker.d.ts +1 -0
- package/dist/plugin/runtime/child-process-worker.js +4 -1
- package/dist/plugin/runtime/child-process-worker.js.map +1 -1
- package/dist/plugin/runtime/node-thread-worker.d.ts +1 -0
- package/dist/plugin/runtime/node-thread-worker.js +2 -0
- package/dist/plugin/runtime/node-thread-worker.js.map +1 -1
- package/dist/plugin/runtime/runtime-worker.d.ts +3 -5
- package/dist/promise-utils.d.ts +13 -0
- package/dist/promise-utils.js +92 -0
- package/dist/promise-utils.js.map +1 -0
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.js +13 -5
- package/dist/runtime.js.map +1 -1
- package/dist/services/plugin.js +1 -1
- package/dist/services/plugin.js.map +1 -1
- package/package.json +2 -2
- package/python/plugin_remote.py +3 -9
- package/python/plugin_repl.py +103 -299
- package/src/plugin/plugin-host-api.ts +1 -1
- package/src/plugin/plugin-host.ts +0 -4
- package/src/plugin/runtime/child-process-worker.ts +6 -1
- package/src/plugin/runtime/node-thread-worker.ts +4 -1
- package/src/plugin/runtime/runtime-worker.ts +3 -5
- package/src/promise-utils.ts +96 -0
- package/src/runtime.ts +15 -6
- package/src/services/plugin.ts +1 -1
package/src/runtime.ts
CHANGED
@@ -16,6 +16,7 @@ import { Parser as TarParser } from 'tar';
|
|
16
16
|
import { URL } from "url";
|
17
17
|
import WebSocket, { Server as WebSocketServer } from "ws";
|
18
18
|
import { computeClusterObjectHash } from './cluster/cluster-hash';
|
19
|
+
import { isClusterAddress } from './cluster/cluster-setup';
|
19
20
|
import { ClusterObject } from './cluster/connect-rpc-object';
|
20
21
|
import { Plugin, PluginDevice, ScryptedAlert, ScryptedUser } from './db-types';
|
21
22
|
import { httpFetch } from './fetch/http-fetch';
|
@@ -33,20 +34,20 @@ import { isConnectionUpgrade, PluginHttp } from './plugin/plugin-http';
|
|
33
34
|
import { WebSocketConnection } from './plugin/plugin-remote-websocket';
|
34
35
|
import { getPluginVolume } from './plugin/plugin-volume';
|
35
36
|
import { getBuiltinRuntimeHosts } from './plugin/runtime/runtime-host';
|
37
|
+
import { timeoutPromise } from './promise-utils';
|
38
|
+
import { RunningClusterWorker } from './scrypted-cluster-main';
|
36
39
|
import { getIpAddress, SCRYPTED_INSECURE_PORT, SCRYPTED_SECURE_PORT } from './server-settings';
|
37
40
|
import { AddressSettings } from './services/addresses';
|
38
41
|
import { Alerts } from './services/alerts';
|
39
42
|
import { Backup } from './services/backup';
|
40
43
|
import { ClusterForkService } from './services/cluster-fork';
|
41
44
|
import { CORSControl } from './services/cors';
|
45
|
+
import { EnvControl } from './services/env';
|
42
46
|
import { Info } from './services/info';
|
43
47
|
import { getNpmPackageInfo, PluginComponent } from './services/plugin';
|
44
48
|
import { ServiceControl } from './services/service-control';
|
45
49
|
import { UsersService } from './services/users';
|
46
50
|
import { getState, ScryptedStateManager, setState } from './state';
|
47
|
-
import { isClusterAddress } from './cluster/cluster-setup';
|
48
|
-
import { RunningClusterWorker } from './scrypted-cluster-main';
|
49
|
-
import { EnvControl } from './services/env';
|
50
51
|
|
51
52
|
interface DeviceProxyPair {
|
52
53
|
handler: PluginDeviceProxyHandler;
|
@@ -678,7 +679,7 @@ export class ScryptedRuntime extends PluginHttp<HttpPluginData> {
|
|
678
679
|
}
|
679
680
|
|
680
681
|
try {
|
681
|
-
this.runPlugin(plugin);
|
682
|
+
await this.runPlugin(plugin);
|
682
683
|
}
|
683
684
|
catch (e) {
|
684
685
|
logger.log('e', `error restarting plugin ${pluginId}`);
|
@@ -691,7 +692,6 @@ export class ScryptedRuntime extends PluginHttp<HttpPluginData> {
|
|
691
692
|
if (pluginHost) {
|
692
693
|
pluginHost.worker.once('error', restart);
|
693
694
|
pluginHost.worker.once('exit', restart);
|
694
|
-
pluginHost.worker.once('close', restart);
|
695
695
|
}
|
696
696
|
else {
|
697
697
|
restart();
|
@@ -754,7 +754,16 @@ export class ScryptedRuntime extends PluginHttp<HttpPluginData> {
|
|
754
754
|
|
755
755
|
}
|
756
756
|
|
757
|
-
runPlugin(plugin: Plugin, pluginDebug?: PluginDebug) {
|
757
|
+
async runPlugin(plugin: Plugin, pluginDebug?: PluginDebug) {
|
758
|
+
const existingPluginHost = this.plugins[plugin._id];
|
759
|
+
const killPromise = existingPluginHost?.worker?.killPromise;
|
760
|
+
if (killPromise) {
|
761
|
+
existingPluginHost?.kill();
|
762
|
+
await timeoutPromise(5000, killPromise).catch(() => {
|
763
|
+
console.warn('plugin worker did not exit in 5 seconds');
|
764
|
+
});
|
765
|
+
}
|
766
|
+
|
758
767
|
const pluginHost = this.loadPlugin(plugin, pluginDebug);
|
759
768
|
this.probePluginDevices(plugin);
|
760
769
|
return pluginHost;
|
package/src/services/plugin.ts
CHANGED
@@ -75,7 +75,7 @@ export class PluginComponent {
|
|
75
75
|
}
|
76
76
|
async reload(pluginId: string) {
|
77
77
|
const plugin = await this.scrypted.datastore.tryGet(Plugin, pluginId);
|
78
|
-
this.scrypted.runPlugin(plugin);
|
78
|
+
await this.scrypted.runPlugin(plugin);
|
79
79
|
}
|
80
80
|
async kill(pluginId: string) {
|
81
81
|
return this.scrypted.plugins[pluginId]?.kill();
|