利用 exec 的异步防止重启造成的错误日志

This commit is contained in:
2023-10-07 22:36:11 +08:00
parent 24b5ab2fce
commit ca57791d51
1 changed files with 3 additions and 5 deletions

View File

@ -120,11 +120,9 @@ app.ws('/entanglement', (ws, req) => {
// WEBHOOK 处理 GitHub 事件
app.post('/webhook', (req, res) => {
console.log('WEBHOOK:', req.body)
return exec('git pull;npm i', (err, stdout, stderr) => {
if (err) return res.status(500).json({ error: err })
return res.json({ stdout, stderr })
})
console.log('WEBHOOK:' + new Date().toLocaleString())
exec('git pull;npm i')
return res.json({ success: true })
})
app.listen(4096, () => console.log('Server started on port 4096'))