我想使用 Grunt 和 rsync 将一些代码从我的计算机 (Windows) 部署到服务器 (Linux)。
我的 Gruntfile.js
是
module.exports = function(grunt) {
grunt.initConfig({
rsync: {
options: {
args: ['--verbose', '--chmod=777'],
exclude: ['*.git', 'node_modules'],
recursive: true
},
production: {
options: {
src: './bitzl.com',
dest: '/home/marcus/bitzl.com',
host: 'marcus@bitzl.com',
syncDest: true
}
}
}
});
grunt.loadNpmTasks('grunt-rsync');
}
请注意,我使用 marcus
的主目录和 chmod=777
只是为了简化测试。
运行 grunt rsync
失败:
Running "rsync:production" (rsync) task
rsyncing ./example.com >>> /home/marcus/bitzl.com
Shell command was: rsync ./bitzl.com marcus@bitzl.com:/home/marcus/bitzl.com --rsh ssh --recursive --delete --delete-exc
luded --exclude=*.git --exclude=node_modules --verbose --chmod=777
ERROR
Error: rsync exited with code 12
Warning: Task "rsync:production" failed. Use --force to continue.
Error: Task "rsync:production" failed.
at Task.<anonymous> (D:\git\bitzl.com\node_modules\grunt\lib\util\task.js:200:15)
at null._onTimeout (D:\git\bitzl.com\node_modules\grunt\lib\util\task.js:236:33)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
Aborted due to warnings.
但是,在没有 Grunt 的情况下从上面运行 rsync 命令工作正常:
rsync ./bitzl.com marcus@bitzl.com:/home/marcus/bitzl.com --rsh ssh --recursive --delete --delete-excluded --exclude=*.git --exclude=node_modules --verbose --chmod=777
Rsync 会提示输入我的公钥的密码(通过 Grunt 它不会)并像微风一样同步。
服务器上的身份验证通过公钥(带密码)进行。密码验证也可以。
我的猜测是密码提示以某种方式被破坏并且 rsync 失败并出现协议(protocol)错误(即 exit code 12 )。
要让 grunt-rsync 在 Windows 上运行,我缺少什么?
更新:
在 Linux VM(通过 Virtualbox/Vagrant 的 Ubuntu 12.04)中,它的工作方式与预期的一样。
最佳答案
原来是 grunt-rsync 中的一个错误。我为 rsyncwrapper 填写的拉取请求已被接受,并且使用最新版本的 grunt-rsync 一切都按预期工作。
如果您仍然遇到问题,请确保您至少安装了 grunt-rsync 版本 0.6.0。
关于windows - 来自 Windows 客户端的 grunt-rsync 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23564277/