child-process

How to debug child Node.JS process in Visual Studio Code?

拜拜、爱过 提交于 2020-01-12 13:56:12
问题 How to debug child Node.JS process in VS Code? Here is the example of the code that I'm trying to debug: var spawn = require('child_process').spawn; var scriptPath = './child-script.js'; var runner_ = spawn('node', [scriptPath]); 回答1: You can easily add a new launch configuration to launch.json that allows you to attach to a running node instance with a specific port: { "name": "Attach to Node", "type": "node", "address": "localhost", "port": 5870, } Just make sure you fork/spawn your node

Piping data from child to parent in nodejs

坚强是说给别人听的谎言 提交于 2020-01-12 04:56:05
问题 I have a nodejs parent process that starts up another nodejs child process. The child process executes some logic and then returns output to the parent. The output is large and I'm trying to use pipes to communicate, as suggested in documentation for child.send() method (which works fine BTW). I would like someone to suggest how to properly build this communication channel. I want to be able to send data from parent to child and also to be able to send data from child to parent. I've started

Can we launch a node command on a mac without node installed when using electron-packager?

一笑奈何 提交于 2020-01-11 12:40:34
问题 When I package an electron app using electron-packager. The app spawns a child process which uses a 'node' command. Now if I try to launch my app in a system with no node installed on it, does the app work? I have been trying to achieve this and facing various issues, the electron community suggested me to use fork method, spawn method with 'Process.execPath' as command and also setting the ELECTRON_RUN_AS_NODE variable but nothing seems to work on my end. Now after doing all this I question

Spawn a mysql process to import a database using node

妖精的绣舞 提交于 2020-01-11 11:28:46
问题 I'm trying to write a node script to automatically import a .sql file. I think I am misunderstanding the way to pass arguments to 'spawn'. Here's what I have: var spawn = require('child_process').spawn; var mysqlimport = spawn('/usr/local/bin/mysql', [ '-u' + database.user, '-p' + database.password, '-h' + database.address, '--default-character-set=utf8', '--comments', '<"' + fileName + '"' ]); mysqlimport .stdout .pipe(logFile) .on('data', function(data) { console.log(data); }) .on('finish',

Spawn a mysql process to import a database using node

别来无恙 提交于 2020-01-11 11:27:09
问题 I'm trying to write a node script to automatically import a .sql file. I think I am misunderstanding the way to pass arguments to 'spawn'. Here's what I have: var spawn = require('child_process').spawn; var mysqlimport = spawn('/usr/local/bin/mysql', [ '-u' + database.user, '-p' + database.password, '-h' + database.address, '--default-character-set=utf8', '--comments', '<"' + fileName + '"' ]); mysqlimport .stdout .pipe(logFile) .on('data', function(data) { console.log(data); }) .on('finish',

How to do multithreading in node js child process

空扰寡人 提交于 2020-01-06 11:50:49
问题 I have a bash script that called for multiple times with unique id and I have used socket io to send messages on stdout function The shell script contains two actions: Action1 Action2 Action2 is a background process so I don't want to wait for the script completion so when the Action1 got completed then I print echo message (msg) which I will capture in the stdout function and then I sent the socket io message inside the stdout function server.js child_process = exec('bash some-file.sh arg1

How to do multithreading in node js child process

こ雲淡風輕ζ 提交于 2020-01-06 11:49:33
问题 I have a bash script that called for multiple times with unique id and I have used socket io to send messages on stdout function The shell script contains two actions: Action1 Action2 Action2 is a background process so I don't want to wait for the script completion so when the Action1 got completed then I print echo message (msg) which I will capture in the stdout function and then I sent the socket io message inside the stdout function server.js child_process = exec('bash some-file.sh arg1

Facing difficulty to stop the stream in child process spawn in Node.js?

橙三吉。 提交于 2020-01-05 09:14:13
问题 I am trying to use Node.js Child process spawn. Below code will execute the certain shell commands and read the data as buffer streams listener provided by spawn process. Bluebird node promise module is used to wrap around the child process. var execSpawn = require('child_process').spawn; var Promise = require('bluebird'); spawnAction = function(path, cmd, cb){ return function(resolve, reject){ cmdExec = execSpawn(path, cmd); var fileData = {} var count = 0; cmdExec.stdout.on('data', function

Facing difficulty to stop the stream in child process spawn in Node.js?

对着背影说爱祢 提交于 2020-01-05 09:13:30
问题 I am trying to use Node.js Child process spawn. Below code will execute the certain shell commands and read the data as buffer streams listener provided by spawn process. Bluebird node promise module is used to wrap around the child process. var execSpawn = require('child_process').spawn; var Promise = require('bluebird'); spawnAction = function(path, cmd, cb){ return function(resolve, reject){ cmdExec = execSpawn(path, cmd); var fileData = {} var count = 0; cmdExec.stdout.on('data', function

using child_process spawn on aws lambda for a python script

放肆的年华 提交于 2020-01-05 07:07:40
问题 I'm trying to run a python script using my javascript file through the child_process.spawn system, but it seems to never run on the aws lambda. The relevant code is : getEntities: function (){ var spawn = require('child_process').spawn; var py = spawn('python', ['mainPythonFile.py']); var outputString = "starting string"; console.log("BEFORE ANY INPUT"); py.stdout.on('data', function (data) { console.log("----Getting information from the python script!---"); outputString += data.toString();