javascript - nodejs child_processes.exec can not return 'nohup' command -
i write function of nodejs execute 'nohup' command , send success result http response.
function _nohup(cmd,res){ var child = exec('nohup ./' + cmd + '.sh &', function (error, stdout, stderr) { res.writeheader(200); res.end("start process success!"); }); } but when call function url address, response data can not return.
child_process.exec() waits child process exit , invokes callback. in case, you've spawned background process, presumably isn't ever exiting.
you want child_process.spawn():
http://nodejs.org/docs/v0.4.9/api/child_processes.html#child_process.spawn
Comments
Post a Comment