mirror of
https://github.com/koush/scrypted.git
synced 2026-04-27 18:30:28 +01:00
server: add explicit hook for main file
This commit is contained in:
@@ -9,7 +9,7 @@ import net from "net";
|
||||
|
||||
export class NodeForkWorker extends ChildProcessWorker {
|
||||
|
||||
constructor(pluginId: string, options: RuntimeWorkerOptions) {
|
||||
constructor(mainFilename: string, pluginId: string, options: RuntimeWorkerOptions) {
|
||||
super(pluginId, options);
|
||||
|
||||
const {env, pluginDebug} = options;
|
||||
@@ -19,7 +19,7 @@ export class NodeForkWorker extends ChildProcessWorker {
|
||||
execArgv.push(`--inspect=0.0.0.0:${pluginDebug.inspectPort}`);
|
||||
}
|
||||
|
||||
this.worker = child_process.fork(require.main.filename, ['child', this.pluginId], {
|
||||
this.worker = child_process.fork(mainFilename, ['child', this.pluginId], {
|
||||
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
|
||||
env: Object.assign({}, process.env, env, {
|
||||
NODE_PATH: path.join(getPluginNodePath(this.pluginId), 'node_modules'),
|
||||
|
||||
@@ -10,11 +10,11 @@ export class NodeThreadWorker extends EventEmitter implements RuntimeWorker {
|
||||
terminated: boolean;
|
||||
worker: worker_threads.Worker;
|
||||
|
||||
constructor(public pluginId: string, options: RuntimeWorkerOptions) {
|
||||
constructor(mainFilename: string, public pluginId: string, options: RuntimeWorkerOptions) {
|
||||
super();
|
||||
const { env } = options;
|
||||
|
||||
this.worker = new worker_threads.Worker(require.main.filename, {
|
||||
this.worker = new worker_threads.Worker(mainFilename, {
|
||||
argv: ['child-thread', this.pluginId],
|
||||
env: Object.assign({}, process.env, env, {
|
||||
NODE_PATH: path.join(getPluginNodePath(this.pluginId), 'node_modules'),
|
||||
|
||||
@@ -58,12 +58,14 @@ export class PythonRuntimeWorker extends ChildProcessWorker {
|
||||
|
||||
args.push(this.pluginId);
|
||||
|
||||
const types = require.resolve('@scrypted/types');
|
||||
const PYTHONPATH = types.substring(0, types.indexOf('@scrypted/types') + '@scrypted/types'.length);
|
||||
this.worker = child_process.spawn(pythonPath, args, {
|
||||
// stdin, stdout, stderr, peer in, peer out
|
||||
stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe'],
|
||||
env: Object.assign({
|
||||
PYTHONUNBUFFERED: '1',
|
||||
PYTHONPATH: path.join(process.cwd(), 'node_modules/@scrypted/types'),
|
||||
PYTHONPATH,
|
||||
}, gstEnv, process.env, env),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user