標籤:
想邊自己寫ruby代碼,邊部署隨時能夠到處查看,heroku網域名稱又不友好,速度在國內又慢。於是乎想起來capistrano,於是學起 ...
capistrano 一點入門認知
https://www.evernote.com/shard/s6/sh/72a2b7c8-d531-4efc-9e16-ac82af2a92b7/e54fca8a9e7014ad87c79e7a7a5538c4
capistrano 新版的安裝
http://capistranorb.com/documentation/getting-started/preparing-your-application/
http://capistranorb.com/
# Deploy in Gemfile
gem ‘capistrano‘, ‘~> 3.2.0‘
完畢安裝即可。並產生capfile等即可了 ...
$bundle exec cap install
具體配置:
$vim config/deploy/production.rb
## content
11 server ‘qzi.me‘, roles: [:demo], port:1234, user: ‘qzi‘
12 task :uptime do |host|
13 on roles(:demo), in: :parallel do
14 uptime = capture(:uptime)
15 hostname = capture(:hostname)
16 puts "#{hostname} reports: #{uptime}"
17 end
18 end
$ cap production uptime
更優寫法:
$vim config/deploy/production.rb
server ‘qzi.me‘, roles: [:demo], port: 1234, user: ‘qzi’
$ vim lib/capistrano/tasks/test.rake
desc "check the uptime on the host"
task :uptime do |host|
on roles(:demo), in: :parallel do
uptime = capture(:uptime)
hostname = capture(:hostname)
puts "#{hostname} reports: #{uptime}"
end
end
$cap -T # 能夠查到你新增加的命令了
ssh 本身先弄免rsa免password登陸。這個是題外話,能夠百度之;
還有就是rails 項目怎麼部署解釋起來得另外去學,比方passenger, unicorn 等都不會非常難;
當然自己要有主機, 網域名稱之類的;
臨時先這樣吧。主機登陸和操作命令都已經點到,以後把筆記再整理一通過與一些撞在了一起 ...
著作權聲明:本文部落格原創文章,部落格,未經同意,不得轉載。
使用 Capistrano 和寫作 Ruby 迭代邊緣部署