node.js - Nodejs Passing argument to fork object
问题描述
How to send "--max_old_space_size=1024" to child process fork? I tried to send this argument as args , argv Note that because I need communication channel, I could not use exec or spawn. So basically I want run my child process
require('child_process').fork('myfile.js');
as
node --max_old_space_size=1024 myfile.js
解决方案
You're looking for the execArgv
property of fork
's options:
require('child_process').fork('myfile.js', {
execArgv: ['--max_old_space_size=1024']
});
Then in myfile.js
you can check it's been considered through process.execArgv
:
console.log(process.execArgv);
Which should output the same as if you directly call:
node --max_old_space_size=1024 myfile.js
This differentiates these 2 types of arguments: node <node's args> file.js <file's args>
推荐阅读
- wpf - ItemsControl 中的子控件被禁用,但我不知道是什么禁用了它们
- kendo-ui - 如何从剑道条形图/柱形图中删除水平网格线?
- image-processing - 在 Keras 图像分类中不会减少的损失验证
- sql - 如何在 SQL 中合并数据
- sql - SQL 连接查询具有跨 3 个表的列总和的视图
- git-bash - Git Bash - 开始时带有“/”的字符串参数正在扩展为文件路径。如何阻止这种情况?
- laravel - Laravel 使用 $request 中的 where 子句和 like 连接数据库表
- azure - 从 PowerShell 部署 LogicApp
- r - 如何选择 group_by 之后未汇总的列?
- google-apps-script - 如何修改当前插入时间戳脚本以在清除单元格时删除时间戳