-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Piping stdout from child process into main process #2151
Comments
I like this idea, that would also support |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Don't you dare to close a Feature Request, Stale Bot 🧐 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is a nifty trick. I solved it a different way by using Event hooks. rsyncQueue.process(function(job, done) {
const rsync = new Rsync(job.data)
rsync.on('log', (message) => job.log(message))`
}) Then inside the class Rsync extends EventEmitter {
...
child.stdout.on('data', (dataObj) => {
const data = dataObj.toString()
this.emit('log', data)
}
} |
Have there been any developments on this? I would much rather have this coming from the package itself than have to set up some custom config for handling the logs |
While working with sub-process workers (sandboxed job processors) I tried to find a good way to get debug information within the job code and in general from the process. (Same as #1021)
The easiest way I came up with is to patch the lib/process/child-pool.js with:
this will pipe any child stdout into the main process stdout with its processFile (e.g.
[src/jobs/processImage.js] found invalid image file '/tmp/x.png'
). (Obviously the transform part is not needed and only adds from which process the output came. This could also be extended with the process pid etc)I think this could be useful for other people as well e.g. behind a config or environment flag.
As I didn't work with
fork
before I don't know about negative side effects for this in production environments, but in my local dev setup it worked and helped me a lot already.The text was updated successfully, but these errors were encountered: