server: add explicit hook for main file

This commit is contained in:
Koushik Dutta
2023-03-19 14:41:02 -07:00
parent 9bafe97ef6
commit abfd0ffe35
10 changed files with 54 additions and 43 deletions

View File

@@ -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'),