From 28ecf02db91ce1403cb4ec903137f5c2ca090f06 Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Sat, 10 Oct 2020 02:35:49 +0800 Subject: [PATCH] init --- routes/index.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/routes/index.js b/routes/index.js index 5062618..f107fa7 100644 --- a/routes/index.js +++ b/routes/index.js @@ -8,20 +8,25 @@ router.post('/server', function(req, res, next) { const updated_at=req.body.repository.updated_at console.info('调用自动部署命令') - const spawnObj = spawn('updateRisk', ['RiskCloudMock'], {encoding: 'utf-8'}); - spawnObj.stdout.on('data', function(chunk) { - console.log(chunk.toString()); - }); - spawnObj.stderr.on('data', (data) => { - console.error(data); - }); - spawnObj.on('close', function(code) { - console.log('close code : ' + code); - }) - spawnObj.on('exit', (code) => { - console.log('exit code : ' + code); + + const promise = new Promise((resolve, reject) => { + const spawnObj = spawn('updateRisk', ['RiskCloudMock'], {encoding: 'utf-8'}); + spawnObj.stdout.on('data', function(chunk) { + console.log(chunk.toString()); + }); + spawnObj.stderr.on('data', (data) => { + console.error(data); + }); + spawnObj.on('close', function(code) { + console.log('close code : ' + code); + }) + spawnObj.on('exit', (code) => { + console.log('exit code : ' + code); + resolve(true) + }) }) + res.json({message:`仓库代码${req.body.repository.ssh_url}部署中`}) });