在nodejs上启动新进程 [英] Start new process on nodejs

查看:639
本文介绍了在nodejs上启动新进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用node.js,我希望当有一个像./calculate这样的url的请求启动一个新进程来进行这些复杂的计算时,我希望即使调用它的脚本,该进程也会继续已完成。
有可能吗?

I'm working with node.js and I want to when there's a request to a url like ./calculate start a new process to make these complex calculations, and I want that process to continue even if the script which called it has finished. Is it possible?

谢谢。

推荐答案

您可以使用本机提供的子流程工具:
http://nodejs.org/api/ child_process.html

You can use the natively provided child process facility: http://nodejs.org/api/child_process.html

并使用unixnohup命令使生成的进程保持活动状态,即使父进程已经死亡。

And use the unix "nohup" command to keep the spawned process alive even if the parent process died.

这篇关于在nodejs上启动新进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆