2016-06-17 91 views
0

需要使用node-js构建后端服务,该服务执行以下操作。Nodejs - 运行外部进程

  1. 接受来自客户端(浏览器)文件上传
  2. 在磁盘上保存和更新数据库与作为保存新的文件名和状态的文件(mongodb
  3. 开始一个长期运行的进程来解析文件(书面在python),并得到反馈(进度,错误,成功),与状态反馈更新DB

我们如何调用#3从node.js的 - 它可能是系统调用像python parse_file.py filename

app.post('/upload',function(req,res, next){ 

     // what should go here to call the process 

     res.writeHead(201, {'Content-type': 'text/plain'}); 
     res.end("File uploaded."); 
    } 
}); 

回答