想边自己写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 等都不会非常难;
当然自己要有主机, 域名之类的;
临时先这样吧。主机登陆和操作命令都已经点到,以后把笔记再整理一通过与一些撞在了一起 ...