想邊自己寫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免密碼登陸,這個是題外話,可以百度之;
還有就是rails 項目怎麼部署解釋起來得另外去學,比如passenger, unicorn 等都不會很難;
當然自己要有主機, 網域名稱之類的;
暫時先這樣吧,主機登陸和操作命令都已經點到,以後把筆記再整理一下再加進來些 ...