我使用cap调用很多来在一堆服务器上运行命令。我还想使用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
这种事情似乎非常有用,所以我确信必须有办法做到这一点......
答案 0 :(得分:10)
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
答案 1 :(得分:1)
这会将所有文件上传到相应的服务器。
上限部署:上传FILES = abc,def
答案 2 :(得分:0)
显示所有任务:
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
答案 3 :(得分:0)
没有cap deploy:upload
的任何来这里的人都可以尝试使用cap invoke
来拉文件而不是推送文件。例如:
cap invoke COMMAND='scp host.where.file.is:/path/to/file/there /target/path/on/remote`