零基礎學習capistrano 使用(-)

學習 Capistrano ,主要考慮用其做代碼的自動化發佈

參考:

https://github.com/capistrano/capistrano

https://github.com/capistrano/capistrano/wiki


http://huacnlee.com/blog/using-nginx-proxy-to-mirror-rubygem-org/

http://ruby.taobao.org/

http://www.mysqlops.com/2011/11/28/rake-code.html


DEPENDENCIES


Net::SSH

Net::SFTP

Net::SCP

Net::SSH::Gateway

HighLine

Ruby ≥ 1.8.7   ########### 注意這個  


安裝

wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz

tar xzvf ruby-2.0.0-p247.tar.gz

cd ruby-2.0.0-p247

./configure

make

make install

ruby -v


wget http://production.cf.rubygems.org/rubygems/rubygems-2.0.6.tgz

tar xzf rubygems-2.0.6.tgz

cd rubygems-2.0.6

/usr/local/bin/ruby setup.rb

gem -v

[root@test-102 ~]# gem env        gem 環境變量

RubyGems Environment:

 - RUBYGEMS VERSION: 2.0.6

 - RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [x86_64-linux]

 - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.0.0

 - RUBY EXECUTABLE: /usr/local/bin/ruby

 - EXECUTABLE DIRECTORY: /usr/local/bin

 - RUBYGEMS PLATFORMS:

   - ruby

   - x86_64-linux

 - GEM PATHS:

    - /usr/local/lib/ruby/gems/2.0.0

    - /root/.gem/ruby/2.0.0

 - GEM CONFIGURATION:

    - :update_sources => true

    - :verbose => true

    - :backtrace => false

    - :bulk_threshold => 1000

    - :sources => ["http://ruby.taobao.org/"]      ############# gem默認安裝完成非這個源地址,因默認源被牆,很慢

 - REMOTE SOURCES:

    - http://ruby.taobao.org/             ############### gem默認安裝完成非這個源地址,因默認源被強,很慢


gem sources --remove https://rubygems.org/

gem sources -a http://ruby.taobao.org/


沒有修改 sources 安裝 capistrano 報錯

[root@test-102 rubygems-2.0.6]# gem install capistrano

ERROR:  Could not find a valid gem 'capistrano' (>= 0), here is why:

         Unable to download data from https://rubygems.org/ - Errno::ETIMEDOUT: Connection timed out - connect(2) (https://rubygems.org/latest_specs.4.8.gz)




安裝 capistrano  前後 gem list  輸出對比

[root@test-102 rubygems-2.0.6]# gem list


*** LOCAL GEMS ***


bigdecimal (1.2.0)

io-console (0.4.2)

json (1.7.7)

minitest (4.3.2)

psych (2.0.0)

rake (0.9.6)

rdoc (4.0.0)

test-unit (2.0.0.0)


gem install capistrano

[root@test-102 ~]# gem list


*** LOCAL GEMS ***


bigdecimal (1.2.0)

capistrano (2.15.5)

highline (1.6.19)

io-console (0.4.2)

json (1.7.7)

minitest (4.3.2)

net-scp (1.1.2)

net-sftp (2.1.2)

net-ssh (2.6.8)

net-ssh-gateway (1.2.0)

psych (2.0.0)

rake (0.9.6)

rdoc (4.0.0)

test-unit (2.0.0.0)



cap -h   capistrano  能幹的事情

cap -H   capistrano 能幹事情詳細說明


沒有注意ruby 版本要求,導致cap 環境檢查報錯,折騰了蠻久,搞煩了,就去看看知乎。回來谷歌再搞

/usr/lib/ruby/gems/1.8/gems/capistrano-2.15.5/lib/capistrano/configuration/actions/file_transfer.rb:39: warning: parenthesize argument(s) for future version

/usr/lib/ruby/gems/1.8/gems/capistrano-2.15.5/lib/capistrano/configuration.rb:48: undefined method `owner' for #<UnboundMethod: Capistrano::Configuration(Object)#taguri> (NoMethodError)

       from /usr/lib/ruby/gems/1.8/gems/capistrano-2.15.5/lib/capistrano/configuration.rb:46:in `select'

       from /usr/lib/ruby/gems/1.8/gems/capistrano-2.15.5/lib/capistrano/configuration.rb:46

       from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'

       from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'

       from /usr/lib/ruby/gems/1.8/gems/capistrano-2.15.5/lib/capistrano.rb:3

       from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'

       from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'

       from /usr/lib/ruby/gems/1.8/gems/capistrano-2.15.5/lib/capistrano/cli.rb:1

       from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'

       from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'

       from /usr/lib/ruby/gems/1.8/gems/capistrano-2.15.5/bin/cap:3

       from /usr/bin/cap:19:in `load'

       from /usr/bin/cap:19

符合依賴版本後,環境檢查,正常

[root@test-102 cap]# cap deploy:check

 * 2013-08-15 15:15:48 executing `deploy:check'

 * executing multiple commands in parallel

   -> "else" :: "test -d /u/apps/set your application name here/releases"

   -> "else" :: "test -d /u/apps/set your application name here/releases"

   -> "else" :: "test -d /u/apps/set your application name here/releases"

   -> "else" :: "test -d /u/apps/set your application name here/releases"

   servers: ["your web-server here", "your app-server here", "your primary db-server here", "your slave db-server here"]

connection failed for: your app-server here (SocketError: getaddrinfo: Name or service not known), your web-server here (SocketError: getaddrinfo: Name or service not known), your primary db-server here (SocketError: getaddrinfo: Name or service not known), your slave db-server here (SocketError: getaddrinfo: Name or service not known)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章