child-process

NodeJS — Fork Child Process with function string instead of file

╄→гoц情女王★ 提交于 2020-01-05 03:45:01
问题 I've looked at the documentation for the fork method, and it only describes providing a file path to the child module file. Does anyone know if it is possible (and undocumented) to pass in the child module directly instead of via a file? Point being, I would like to dynamically generate the module, then create a child process with it. 回答1: This would not be possible -- fork() creates a completely different process that do not share context or variables with its parent process. One option you

VSCode will not stop on breakpoints when first node prcess forks a second

最后都变了- 提交于 2020-01-04 05:29:07
问题 The first issue is that there is some conflict error when you do the following from your app.js file and hit F5 to debug: var cp = require('child_process'); var node2 = cp.fork('./app_FORK.js'); Error: listen EADDRINUSE :::15838 at Object.exports._errnoException (util.js:856:11) I had the same issue with VS Community, so I did the following there and it worked: var node2 = cp.fork('./app_FORK.js', [], { execArgv: ['--debug=5859'] }); However, in VS Code, it does not seem to work. I place

How do I convert an h.264 stream to MP4 using ffmpeg and pipe the result to the client?

 ̄綄美尐妖づ 提交于 2020-01-02 08:11:30
问题 I have an h.264 encoded stream of video on my server (node.js) and I want to use ffmpeg to convert it to an MP4 stream. Then I want to pipe that MP4 stream from the child process to the client using the response of an HTTP server that I have set up. I am very confused about all the options ffmpeg has and not sure how to pipe the output of the child process to the HTTP response. I have tried several combinations of ffmpeg options but the video does not play in the browser (or show any sign of

Passing 2 stdin arguments to a ImageMagick child_process

↘锁芯ラ 提交于 2020-01-02 07:36:08
问题 I have certain limitations that I won't specify that require me to use ImageMagick as a child-process. I have multiple base 64 strings of jpg files which I want ImageMagick to process. Specifically I want ImageMagick to join the jpg files together. If I had 2 regular jpg files then from the command line I would use the following format. node convert in_1.jpg in_2.jpg +append out.jpg in a js file I would use var spawn, magicCommands, imagic; spawn = require('child_process').spawn;

Stripe with React JS

孤街浪徒 提交于 2020-01-01 09:06:14
问题 I need to create token with Stripe.js in React JS, but I can't find any easy way. In node.js I would do something like this: stripeClient.tokens.create({ card: { number: '4242424242424242', exp_month: 12, exp_year: 2050, cvc: '123' } But the Stripe npm module doesn't work for me in React JS. I'm getting error: Cannot resolve module 'child_process' So since this is node pibrary obviously, I would like to use <script type="text/javascript" src="https://js.stripe.com/v2/"></script> But I'm not

I/O redirection from child process using pipes - winapi

笑着哭i 提交于 2020-01-01 07:01:07
问题 I'm working with an application that offers an api so that scripting it is easier. Basically, when you write valid input, it outputs an answer. I would like to use that output to sends more input, e.g.: Input: <nodes> Output: 1, 56, 23 Input <56> Output: "Apple" What I'd like to do is a program that writes to the target process STDIN, then reads the output from it's STDOUT. To do that, I mostly took the code from there: Creating a Child Process with Redirected Input and Output (Windows) -

How to see stdout of a phantomjs child process using node.js?

故事扮演 提交于 2019-12-30 07:10:31
问题 In the following node.js code, I normally have to wait for the phantomjs child process to terminate to get the stdout. I am wondering if there is any way to see the stdout while the phantomjs child process is running? var path = require('path') var childProcess = require('child_process') var phantomjs = require('phantomjs') var binPath = phantomjs.path var childArgs = [ path.join(__dirname, 'phantomjs-script.js'), ] childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) { //

How to get child process from parent process

大兔子大兔子 提交于 2019-12-28 04:50:22
问题 Is it possible to get the child process id from parent process id in shell script? I have a file to execute using shell script, which leads to a new process process1 (parent process). This process1 has forked another process process2 (child process). Using script, I'm able to get the pid of process1 using the command: cat /path/of/file/to/be/executed but i'm unable to fetch the pid of the child process. 回答1: Just use : pgrep -P $your_process1_pid 回答2: I am not sure if I understand you

How to apply clustering/spawing child process techniques for Node.js application having bouth IO bound and CPU bound tasks?

三世轮回 提交于 2019-12-25 07:15:13
问题 I'm working on a IOT project where the Node.js application perform following tasks: 1. Reading stream of messages using asynchronous messaging library (IO bound) 2. Sending the messages to web service where machine learning happens based on the messages that were sent by Node.js application (IO bound as only API call is involved) 3. Receive the pattern generated as a result of machine learning from web service (using REST API) 4. Compare the pattern against the real-time streaming messages

How do I get information from PROC about a child process

ぃ、小莉子 提交于 2019-12-25 03:35:54
问题 I am trying to write a program that takes a few processes as its arguments. Then the parent process executes each child process and prints out a few statistics with regard to the same. Example: /generate ls -l //Would result in a program that prints out some statistics with regard to ls -l (Specifically its system time, user time and number of context switches). Instead of using the getrusage() function, I would like to get the necessary information from the Proc file system. Now my