2
我有一個節點應用程序,我使用bitbucket中的webhook來觸發bash腳本來運行一些命令來部署我的應用程序。它工作,但我不能查看任何正在運行的命令(即進度命令echo'd)。我怎樣才能做到這一點?如何從節點腳本執行時查看bash命令
下面是相關代碼:
var shellPath = path.join(__dirname + '../../deploy/deploy.sh');
var exec = require('child_process').exec;
function puts(error, stdout, stderr) {
console.log('stout: ', stdout)
console.log('error: ', error)
console.log('stderr: ', stderr)
}
exec(shellPath, puts);
deploy.sh -
echo Preparing to Git Fetch
git reset --hard origin/master
echo Preparing to clean
git clean -f
echo Preparing to pull
git pull
echo preparing to pull
npm i --production
echo preparing to restart pm2
pm2 restart client-www
echo Finished deploy
請參見:[如何調試bash腳本?](http://unix.stackexchange.com/q/155551/74329) – Cyrus