我不希望我的孩子进程在父母去世时退出。
var logPath = `${global.appPath}/logs/detached-job-${detachedJobId}.txt`
var options = { detached: true, stdio: ['ignore', fs.openSync(logPath, 'a'), fs.openSync(logPath, 'a')], env: process.env }
var childProcess = child_process.spawn('node', [`${global.appPath}/backend/bin/run-detached-job.js`, `${detachedJobId}`], options)
childProcess.unref()
await new Promise(function (resolve, reject) {
childProcess.on('error', reject)
childProcess.on('close', function (code) {
if (code !== 0) {
return reject(new Error('Invalid exit code ' + code))
}
resolve(code)
})
})
这不起作用。 nodejs v10.13.0,Linux 4.4.0-143通用