Files
CompanyProject/moehu/moehu-backend/pull/index.js
2024-09-27 01:32:49 +08:00

35 lines
1.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const app = require('express')(),
exec = require('child_process').execFile;
app.post('/pull', (req, res) => {
exec('/root/moehu-backend/pull/pull.sh',{
cwd: './',
encoding: 'utf8',
stdio: 'inherit'
}, (err, stdout, stderr) => {
if (err) {
console.log(`命令执行错误 err${err}`)
console.log(`命令执行错误 stdout${stdout}`)
console.log(`命令执行错误 stderr ${stderr}`)
res.json({
title: 'error',
message: err.message
})
} else {
console.log(`命令成功错误 err${err}`)
console.log(`命令成功错误 stdout${stdout}`)
console.log(`命令成功错误 stderr ${stderr}`)
res.json({
title: 'success1',
})
}
res.json({
title: 'success2',
})
});
})
app.listen(1314, () => {
console.log('Node.js自动部署运行在: 1314')
})