Skip to main content

进程重启

node端:

const exec = require('child_process').exec

// 重启pm2
router.get('/pm2/restart', (req, res, next) => {
exec('pm2 restart 2', (error) => { // 2是进程id
if(error) {
console.error(`exec error: ${error}`)
return
}
console.log('pm2 restart success...')
})
res.send('pm2 restart exec.')
})

前端get请求

$.get('/pm2/restart')