@scrypted/server 0.115.38 → 0.115.40
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/runtime/node-fork-worker.d.ts +1 -0
- package/dist/plugin/runtime/node-fork-worker.js +8 -1
- package/dist/plugin/runtime/node-fork-worker.js.map +1 -1
- package/dist/scrypted-main-exports.d.ts +0 -1
- package/dist/scrypted-main-exports.js +2 -5
- package/dist/scrypted-main-exports.js.map +1 -1
- package/package.json +1 -1
- package/src/plugin/runtime/node-fork-worker.ts +8 -1
- package/src/scrypted-main-exports.ts +2 -4
@@ -1,6 +1,7 @@
|
|
1
1
|
import { RpcMessage, RpcPeer } from "../../rpc";
|
2
2
|
import { ChildProcessWorker } from "./child-process-worker";
|
3
3
|
import { RuntimeWorkerOptions } from "./runtime-worker";
|
4
|
+
export declare function isChildProcess(): boolean;
|
4
5
|
export declare class NodeForkWorker extends ChildProcessWorker {
|
5
6
|
constructor(mainFilename: string, pluginId: string, options: RuntimeWorkerOptions);
|
6
7
|
setupRpcPeer(peer: RpcPeer): void;
|
@@ -4,10 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.NodeForkWorker = void 0;
|
7
|
+
exports.isChildProcess = isChildProcess;
|
7
8
|
const child_process_1 = __importDefault(require("child_process"));
|
8
9
|
const net_1 = __importDefault(require("net"));
|
9
10
|
const socket_serializer_1 = require("../socket-serializer");
|
10
11
|
const child_process_worker_1 = require("./child-process-worker");
|
12
|
+
function isChildProcess() {
|
13
|
+
return process.argv[2] === 'child' || process.argv[2] === 'fork' || process.argv[2] === 'child-thread';
|
14
|
+
}
|
11
15
|
class NodeForkWorker extends child_process_worker_1.ChildProcessWorker {
|
12
16
|
constructor(mainFilename, pluginId, options) {
|
13
17
|
super(pluginId, options);
|
@@ -16,7 +20,10 @@ class NodeForkWorker extends child_process_worker_1.ChildProcessWorker {
|
|
16
20
|
if (pluginDebug) {
|
17
21
|
execArgv.push(`--inspect=0.0.0.0:${pluginDebug.inspectPort}`);
|
18
22
|
}
|
19
|
-
this.worker = child_process_1.default.fork(mainFilename, [
|
23
|
+
this.worker = child_process_1.default.fork(mainFilename, [
|
24
|
+
isChildProcess() ? 'fork' : 'child',
|
25
|
+
this.pluginId
|
26
|
+
], {
|
20
27
|
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
|
21
28
|
env: Object.assign({}, process.env, env),
|
22
29
|
serialization: 'advanced',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"node-fork-worker.js","sourceRoot":"","sources":["../../../src/plugin/runtime/node-fork-worker.ts"],"names":[],"mappings":";;;;;;
|
1
|
+
{"version":3,"file":"node-fork-worker.js","sourceRoot":"","sources":["../../../src/plugin/runtime/node-fork-worker.ts"],"names":[],"mappings":";;;;;;AAOA,wCAEC;AATD,kEAA0C;AAC1C,8CAAsB;AAEtB,4DAAgE;AAChE,iEAA4D;AAG5D,SAAgB,cAAc;IAC1B,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC;AAC3G,CAAC;AAED,MAAa,cAAe,SAAQ,yCAAkB;IAElD,YAAY,YAAoB,EAAE,QAAgB,EAAE,OAA6B;QAC7E,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAEzB,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAErC,MAAM,QAAQ,GAAa,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACpD,IAAI,WAAW,EAAE,CAAC;YACd,QAAQ,CAAC,IAAI,CAAC,qBAAqB,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC;QAClE,CAAC;QAED,IAAI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,IAAI,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,MAAM;gBACZ,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;YACnD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE;gBAC5D,IAAI,CAAC,IAAI,MAAM;oBACX,MAAM,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACP,CAAC;QACD,OAAO,CAAC,EAAE,CAAC;YACP,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACL,CAAC;IAED,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC;IAC5B,CAAC;CACJ;AA7DD,wCA6DC"}
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.isChildProcess = isChildProcess;
|
7
6
|
const dns_1 = __importDefault(require("dns"));
|
8
7
|
const dotenv_1 = __importDefault(require("dotenv"));
|
9
8
|
const fs_1 = __importDefault(require("fs"));
|
@@ -15,9 +14,7 @@ const vm_1 = __importDefault(require("vm"));
|
|
15
14
|
const plugin_error_1 = require("./plugin/plugin-error");
|
16
15
|
const plugin_volume_1 = require("./plugin/plugin-volume");
|
17
16
|
const rpc_1 = require("./rpc");
|
18
|
-
|
19
|
-
return process_1.default.argv[2] === 'child' || process_1.default.argv[2] === 'child-thread';
|
20
|
-
}
|
17
|
+
const node_fork_worker_1 = require("./plugin/runtime/node-fork-worker");
|
21
18
|
function start(mainFilename, options) {
|
22
19
|
// Allow including a custom file path for platforms that require
|
23
20
|
// compatibility hacks. For example, Android may need to patch
|
@@ -38,7 +35,7 @@ function start(mainFilename, options) {
|
|
38
35
|
// The workaround is to favor IPv4.
|
39
36
|
dns_1.default.setDefaultResultOrder('ipv4first');
|
40
37
|
(0, rpc_1.startPeriodicGarbageCollection)();
|
41
|
-
if (
|
38
|
+
if ((0, node_fork_worker_1.isChildProcess)()) {
|
42
39
|
// plugins should never crash. this handler will be removed, and then readded
|
43
40
|
// after the plugin source map is retrieved.
|
44
41
|
process_1.default.on('uncaughtException', e => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scrypted-main-exports.js","sourceRoot":"","sources":["../src/scrypted-main-exports.ts"],"names":[],"mappings":";;;;;
|
1
|
+
{"version":3,"file":"scrypted-main-exports.js","sourceRoot":"","sources":["../src/scrypted-main-exports.ts"],"names":[],"mappings":";;;;;AAAA,8CAAsB;AACtB,oDAA4B;AAC5B,4CAAoB;AACpB,gDAAwB;AACxB,sDAA8B;AAC9B,oDAA4B;AAC5B,4CAAoB;AACpB,4CAAoB;AACpB,wDAAoD;AACpD,0DAA2D;AAC3D,+BAAuE;AAEvE,wEAAmE;AAGnE,SAAS,KAAK,CAAC,YAAoB,EAAE,OAEpC;IACG,gEAAgE;IAChE,8DAA8D;IAC9D,gBAAgB;IAChB,IAAI,iBAAO,CAAC,GAAG,CAAC,2BAA2B,IAAI,YAAE,CAAC,UAAU,CAAC,iBAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,EAAE,CAAC;QACpG,OAAO,CAAC,iBAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC;QACjB,YAAE,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAA;QACpC,UAAU,CAAC,EAAE,GAAG,YAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,gBAAM,CAAC,GAAG,CAAC,iBAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAA;IACvF,CAAC;IAED,u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,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;AACL,CAAC;AAED,kBAAe,KAAK,CAAC"}
|
package/package.json
CHANGED
@@ -5,6 +5,10 @@ import { SidebandSocketSerializer } from "../socket-serializer";
|
|
5
5
|
import { ChildProcessWorker } from "./child-process-worker";
|
6
6
|
import { RuntimeWorkerOptions } from "./runtime-worker";
|
7
7
|
|
8
|
+
export function isChildProcess() {
|
9
|
+
return process.argv[2] === 'child' || process.argv[2] === 'fork' || process.argv[2] === 'child-thread';
|
10
|
+
}
|
11
|
+
|
8
12
|
export class NodeForkWorker extends ChildProcessWorker {
|
9
13
|
|
10
14
|
constructor(mainFilename: string, pluginId: string, options: RuntimeWorkerOptions) {
|
@@ -17,7 +21,10 @@ export class NodeForkWorker extends ChildProcessWorker {
|
|
17
21
|
execArgv.push(`--inspect=0.0.0.0:${pluginDebug.inspectPort}`);
|
18
22
|
}
|
19
23
|
|
20
|
-
this.worker = child_process.fork(mainFilename, [
|
24
|
+
this.worker = child_process.fork(mainFilename, [
|
25
|
+
isChildProcess() ? 'fork': 'child',
|
26
|
+
this.pluginId
|
27
|
+
], {
|
21
28
|
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
|
22
29
|
env: Object.assign({}, process.env, env),
|
23
30
|
serialization: 'advanced',
|
@@ -10,10 +10,8 @@ import { PluginError } from './plugin/plugin-error';
|
|
10
10
|
import { getScryptedVolume } from './plugin/plugin-volume';
|
11
11
|
import { RPCResultError, startPeriodicGarbageCollection } from './rpc';
|
12
12
|
import type { Runtime } from './scrypted-server-main';
|
13
|
+
import { isChildProcess } from './plugin/runtime/node-fork-worker';
|
13
14
|
|
14
|
-
export function isChildProcess() {
|
15
|
-
return process.argv[2] === 'child' || process.argv[2] === 'child-thread'
|
16
|
-
}
|
17
15
|
|
18
16
|
function start(mainFilename: string, options?: {
|
19
17
|
onRuntimeCreated?: (runtime: Runtime) => Promise<void>,
|
@@ -42,7 +40,7 @@ function start(mainFilename: string, options?: {
|
|
42
40
|
|
43
41
|
startPeriodicGarbageCollection();
|
44
42
|
|
45
|
-
if (
|
43
|
+
if (isChildProcess()) {
|
46
44
|
// plugins should never crash. this handler will be removed, and then readded
|
47
45
|
// after the plugin source map is retrieved.
|
48
46
|
process.on('uncaughtException', e => {
|