SOLUTIONCapistrano的無法部署到遠程服務器
解決的辦法是添加以下production.rb的頂部:
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_ruby_string, '[email protected]' # Or whatever env you want it to run in.
set :rvm_bin_path, '/usr/local/rvm/bin'
我之前缺少的部分是set :rvm_bin_path, '/usr/local/rvm/bin'
我」我以前從未在Capistrano部署中使用過這種配置設置,而且我已經完成了一些工作。噢,所有這些工作都在一天之內。 Credit在irc.freenode.net的#rvm頻道中轉到tonyflint!
原貼
克里夫指出
- 我運行一個系統中安裝RVM的
- 我通過Capistrano的
我部署米目前傻眼了。基本上發生了什麼是我試圖通過卡皮斯特拉諾進行部署,並且失敗,很難。這裏是我的deploy.rb和production.rb文件的pastie(我正在做一個多階段環境,省略了staging.rb文件,因爲它工作正常)。 http://pastie.org/2523675
這裏是cap production deploy:setup
輸出:
$ cap production deploy:setup
* executing `production'
triggering start callbacks for `deploy:setup'
* executing `multistage:ensure'
* executing `deploy:setup'
* executing "sudo -p 'sudo password: ' mkdir -p /var/www/html/dataserver /var/www/html/dataserver/releases /var/www/html/dataserver/shared /var/www/html/dataserver/shared/system /var/www/html/dataserver/shared/log /var/www/html/dataserver/shared/pids"
servers: ["omitted"]
Password:
[omitted] executing command
*** [err :: omitted] sudo
*** [err :: omitted] :
*** [err :: omitted] sorry, you must have a tty to run sudo
*** [err :: omitted]
command finished in 60ms
failed: "sh -c 'sudo -p '\\''sudo password: '\\'' mkdir -p /var/www/html/dataserver /var/www/html/dataserver/releases /var/www/html/dataserver/shared /var/www/html/dataserver/shared/system /var/www/html/dataserver/shared/log /var/www/html/dataserver/shared/pids'" on omitted
現在,我得到爲什麼發生這種情況。我正在遠程嘗試使用sudo,這是一個安全禁止。所以,這意味着我需要使用default_run_options[:pty] = true
。所以我取消註釋並再次運行cap production deploy:setup
,並且所有運行都很好,並且很花哨。部署get的安裝目錄結構和一切。真棒。現在,我嘗試運行cap production deploy
和這裏的輸出:
$ cap production deploy
* executing `production'
triggering start callbacks for `deploy'
* executing `multistage:ensure'
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "hg log -r default --template '{node|short}'"
command finished in 52ms
* executing "if [ -d /var/www/html/dataserver/shared/cached-copy ]; then hg pull --repository /var/www/html/dataserver/shared/cached-copy https://cowfish.unh.edu/hg/DataServerApp && hg update --repository /var/www/html/dataserver/shared/cached-copy --clean 6979cec4fc00; else hg clone --noupdate https://cowfish.unh.edu/hg/DataServerApp /var/www/html/dataserver/shared/cached-copy && hg update --repository /var/www/html/dataserver/shared/cached-copy --clean 6979cec4fc00; fi"
servers: ["omitted"]
Password:
[omitted] executing command
** [omitted :: out] warning: certificate for omitted can't be verified (Python too old)
** [omitted :: out] http authorization required
** [omitted :: out] realm: Mercurial Project Repository
** [omitted :: out] user:
** [omitted :: out] d
** [omitted :: out] e
** [omitted :: out] p
** [omitted :: out] l
** [omitted :: out] o
** [omitted :: out] y
** [omitted :: out]
** [omitted :: out] password:
** [omitted :: out]
** [omitted :: out] warning: certificate for omitted can't be verified (Python too old)
** [omitted :: out] warning: certificate for omitted can't be verified (Python too old)
** [omitted :: out] warning: certificate for omitted can't be verified (Python too old)
** [omitted :: out] requesting all changes
** [omitted :: out] warning: certificate for omitted can't be verified (Python too old)
** [omitted :: out] warning: certificate for omitted can't be verified (Python too old)
** [omitted :: out] adding changesets
** [omitted :: out] adding manifests
** adding file changes
** [omitted :: out] added 11 changesets with 187 changes to 125 files
** [omitted :: out] warning: certificate for omitted can't be verified (Python too old)
** [omitted :: out] warning: certificate for omitted can't be verified (Python too old)
** [omitted :: out] 114 files updated, 0 files merged, 0 files removed, 0 files unresolved
command finished in 1332ms
copying the cached version to /var/www/html/dataserver/releases/20110912233835
* executing "cp -RPp /var/www/html/dataserver/shared/cached-copy /var/www/html/dataserver/releases/20110912233835 && (echo 6979cec4fc00 > /var/www/html/dataserver/releases/20110912233835/REVISION)"
servers: ["omitted"]
[omitted] executing command
command finished in 23ms
* executing `deploy:finalize_update'
* executing "chmod -R g+w /var/www/html/dataserver/releases/20110912233835"
servers: ["omitted"]
[omitted] executing command
command finished in 7ms
* executing "rm -rf /var/www/html/dataserver/releases/20110912233835/log /var/www/html/dataserver/releases/20110912233835/public/system /var/www/html/dataserver/releases/20110912233835/tmp/pids &&\\\n mkdir -p /var/www/html/dataserver/releases/20110912233835/public &&\\\n mkdir -p /var/www/html/dataserver/releases/20110912233835/tmp &&\\\n ln -s /var/www/html/dataserver/shared/log /var/www/html/dataserver/releases/20110912233835/log &&\\\n ln -s /var/www/html/dataserver/shared/system /var/www/html/dataserver/releases/20110912233835/public/system &&\\\n ln -s /var/www/html/dataserver/shared/pids /var/www/html/dataserver/releases/20110912233835/tmp/pids"
servers: ["omitted"]
[omitted] executing command
command finished in 8ms
* executing "find /var/www/html/dataserver/releases/20110912233835/public/images /var/www/html/dataserver/releases/20110912233835/public/stylesheets /var/www/html/dataserver/releases/20110912233835/public/javascripts -exec touch -t 201109122338.35 {} ';'; true"
servers: ["omitted"]
[omitted] executing command
** [out :: omitted] find: /var/www/html/dataserver/releases/20110912233835/public/images: No such file or directory
** [out :: omitted] find: /var/www/html/dataserver/releases/20110912233835/public/stylesheets: No such file or directory
** [out :: omitted] find: /var/www/html/dataserver/releases/20110912233835/public/javascripts: No such file or directory
command finished in 6ms
* executing `deploy:symlink'
* executing "rm -f /var/www/html/dataserver/current && ln -s /var/www/html/dataserver/releases/20110912233835 /var/www/html/dataserver/current"
servers: ["omitted"]
[omitted] executing command
command finished in 6ms
** transaction: commit
* executing `deploy:restart'
* executing "sudo -p 'sudo password: ' touch /var/www/html/dataserver/current/tmp/restart.txt"
servers: ["omitted"]
[omitted] executing command
command finished in 10ms
triggering after callbacks for `deploy'
* executing `deploy:migrate'
triggering before callbacks for `deploy:migrate'
* executing `sqlite3:link_configuration_file'
* executing "ln -nsf /var/www/html/dataserver/shared/sqlite_config.yml /var/www/html/dataserver/releases/20110912233835/config/database.yml"
servers: ["omitted"]
[omitted] executing command
command finished in 6ms
* executing "cd /var/www/html/dataserver/releases/20110912233835 && rake RAILS_ENV=production db:migrate"
servers: ["omitted"]
[omitted] executing command
** [out :: omitted] sh: rake: command not found
command finished in 5ms
failed: "sh -c 'cd /var/www/html/dataserver/releases/20110912233835 && rake RAILS_ENV=production db:migrate'" on omitted
所以看來,無論環境已經加載無法看到rake
。要查看路徑中加載的內容,我創建了一個部署任務,以下是輸出:
$ cap production test_path
* executing `production'
triggering start callbacks for `test_path'
* executing `multistage:ensure'
* executing `test_path'
* executing "echo $PATH"
servers: ["omitted"]
Password:
[omitted] executing command
** [out :: omitted] /usr/local/bin:/bin:/usr/bin
command finished in 11ms
* executing "echo $rvm_path"
servers: ["omitted"]
[omitted] executing command
** [out :: omitted]
command finished in 5ms
現在您會注意到該路徑絕對不正確。對於建立會話的用戶,它應該如下:
/usr/local/rvm/gems/[email protected]/bin:/usr/local/rvm/gems/[email protected]/bin:/usr/local/rvm/rubies/ruby-1.9.2-p290/bin:/usr/local/rvm/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/lpeabody/bin
再次,我得到爲什麼這不起作用。這是因爲我運行default_run_options[:pty] = true
我的環境越來越重,至少那是我現在的理論。所以,畢竟,我留下了結論 - 我需要以某種方式加載我的環境,以便耙機可以在遠程啓用sudo的情況下運行。
現在,我知道我不是唯一需要這樣做的人,所以任何指針或提示將不勝感激。我已經絞盡腦汁,爲了現在8小時的大部分時間,我需要儘快部署這款應用。