Mina works really fast because it’s a deploy Bash script generator. It generates an entire procedure as a Bash script and runs it remotely in the server.
直接生成 bash 脚本在服务端运行,比 capistrano 快多了
这两天刚用它部署了 prd 用了个好东西 share 一下 https://github.com/alfuken/mina-rails-unicorn-nginx-god
刚测试了一下,capistrano 通过 ssh 运行命令没有想象的那么慢啊。 在 deploy.rb 尾部加了 10 个 task
after "deploy:update_code", :test1
task :test1 do
run "echo 1"
end
after "deploy:update_code", :test2
task :test2 do
run "echo 2"
end
after "deploy:update_code", :test3
task :test3 do
run "echo 3"
end
after "deploy:update_code", :test4
task :test4 do
run "echo 4"
end
after "deploy:update_code", :test5
task :test5 do
run "echo 5"
end
after "deploy:update_code", :test6
task :test6 do
run "echo 6"
end
after "deploy:update_code", :test7
task :test7 do
run "echo 7"
end
after "deploy:update_code", :test8
task :test8 do
run "echo 8"
end
after "deploy:update_code", :test9
task :test9 do
run "echo 9"
end
after "deploy:update_code", :test10
task :test10 do
run "echo 10"
end
然后运行这 10 个 task 共用去了 3 秒左右,每个 task 大约 0.3 秒 (美国 vps)
* 2013-02-03 00:05:42 executing `test1'
* executing "echo 1"
servers: ["blog.bccn.net"]
[blog.bccn.net] executing command
** [out :: blog.bccn.net] 1
command finished in 351ms
* 2013-02-03 00:05:42 executing `test2'
* executing "echo 2"
servers: ["blog.bccn.net"]
[blog.bccn.net] executing command
** [out :: blog.bccn.net] 2
command finished in 367ms
* 2013-02-03 00:05:42 executing `test3'
* executing "echo 3"
servers: ["blog.bccn.net"]
[blog.bccn.net] executing command
** [out :: blog.bccn.net] 3
command finished in 3
粗略算了一下,用 mina 大约能节省三分之一的时间,30 秒的部署任务缩短到 20 秒
我有点不打算换了,一开始我看了 vlad 的介绍,没用 capistrano,用 vlad,结果用了一段时间感觉各种不舒服,最终还是转回 capistrano,发现挺好用的,也明白了一点,啥东西,还是要用的人多的才保险一点,@Rei 说的没错,capistrano 的问题不是没文档,而是文档太乱