我经常使用cap invoke在一堆服务器上运行命令。我还想使用capistrano将单个文件推送到一堆服务器。
一开始我以为PUT会这样做,但PUT会让您为文件创建数据。我不想这样做,我只想将运行capistrano命令的机器上的现有文件复制到其他机器上。
如果我能做这样的事情,那就太酷了:
host1$ cap HOSTS=f1.foo.com,f2.foo.com,f3.foo.com COPY /tmp/bar.bin
我希望将host1:/tmp/bar.bin复制到f1.foo.com:/tmp/bar.bin和f2.foo.com://tmp/bar-bin和f3.foo.com/tmp/bar.bin
这种东西看起来很有用,所以我相信一定有办法做到这一点。。。
upload(from, to, options={}, &block)
上载操作将文件存储在当前任务所针对的所有服务器上的给定路径上。
如果您以前使用过deploy:upload任务,那么您可能已经知道该方法是如何工作的。它获取要上载的资源的路径和远程服务器上的目标路径。
desc "Uploads CHANGELOG.txt to all remote servers."
task :upload_changelog do
upload("#{RAILS_ROOT}/CHANGELOG.txt", "#{current_path}/public/CHANGELOG")
end
源
这会将所有文件上传到相应的服务器。
cap-deploy:上传FILES=abc,定义
显示所有任务:
cap -T
cap deploy # Deploys your project.
cap deploy:check # Test deployment dependencies.
cap deploy:cleanup # Clean up old releases.
cap deploy:cold # Deploys and starts a `cold'...
cap deploy:create_symlink # Updates the symlink to the ...
cap deploy:migrations # Deploy and run pending migr...
cap deploy:pending # Displays the commits since ...
cap deploy:pending:diff # Displays the `diff' since y...
cap deploy:rollback # Rolls back to a previous ve...
cap deploy:rollback:code # Rolls back to the previousl...
cap deploy:setup # Prepares one or more server...
cap deploy:symlink # Deprecated API.
cap deploy:update # Copies your project and upd...
cap deploy:update_code # Copies your project to the ...
cap deploy:upload # Copy files to the currently...
cap deploy:web:disable # Present a maintenance page ...
cap deploy:web:enable # Makes the application web-a...
cap integration # Set the target stage to `in...
cap invoke # Invoke a single command on ...
cap multistage:prepare # Stub out the staging config...
cap production # Set the target stage to `pr...
cap shell # Begin an interactive Capist...
您可以使用:
cap deploy:upload
请参阅:https://github.com/capistrano/capistrano/wiki/Capistrano-Tasks#deployupload
任何没有cap deploy:upload
的人都可以尝试使用cap invoke
来拉取文件,而不是推送文件。例如:
cap invoke COMMAND='scp host.where.file.is:/path/to/file/there /target/path/on/remote`