2014-11-21 43 views
1

我無法啓動服務器我的應用程序,因爲下面的錯誤後,使用錯誤的紅寶石版本的獨角獸崩潰:因爲部署

/home/blabla/.rvm/gems/ruby-2.1.0/bin/ruby/2.1.0/bin/unicorn", "-E", "beta", "-c", "/var/www/testenvir/releases/20141117005244/config/unicorn.rb", "-D", {16=>#<Kgio::UNIXServer:fd 16>}] (in /var/www/testenvir/releases/20141121053734) 

/home/blabla/.rvm/gems/[email protected]/gems/bundler-1.6.3/lib/bundler/definition.rb:390:in `validate_ruby!': Your Ruby version is 2.1.0, but your Gemfile specified 2.0.0 (Bundler::RubyVersionMismatch) 

錯誤是自descritive,但我不知道如何解決這個問題,因爲我有我的Gemfile腳本:

ruby '2.0.0' 

在我Capistrano的部署腳本:

set :rvm_ruby_string, 'ruby-2.0.0-p353' 
set :bundle_dir, "/home/blabla/.rvm/gems/ruby-2.0.0-p353/bin" 

在我的服務器,我把我的環境變量如下:

rvm use ruby-2.0.0-p353 

和env RAILS_ENV的輸出= testenvir捆綁高管紅寶石-v是:

ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux] 

我可以通過連接驗證

=* ruby-2.0.0-p353 [ x86_64 ] 
    ruby-2.1.0 [ x86_64 ] 

最後我崩潰命令在試圖推出以下命令眼睛腳本定義:即rvm list產生新的終端:

bundle exec unicorn -E #{RAILS_ENV} -C#{working_dir}/config/unicorn.rb -D 

我證實#{working_directory的}和#{RAILS_ENV}是正確的,所以我想了解硬編碼(作爲第一步驟)中,bundleunicorn的路徑,因爲它們是一個從2.1採取.0而不是2.0.0-p353(我得到的錯誤,在unicorn.log ...),但它沒有工作(墜毀與另一個錯誤...)

我也檢查了$ PATH, $ GEM_HOME,$ GEM_PATH和$ RUBY_VERSION,它們都指向2.0.0-p353版本。事實上,我做了一個printenv,並尋找一個可能的變量,分配給它的ruby-2.1.0,但是我找不到任何變量!

我檢查了我的應用程序的所有文件,但是我在某處分配了ruby-2.1.0,但是我沒有找到任何相關的參考。他們都被設置爲ruby-2.0.0-p353。

我的問題是:

有沒有,我很想念我應該在哪裏指定我想要的紅寶石版本另一個地方?我應該如何在服務器上設置我的ruby版本,而不是我做了什麼?

謝謝!

UPDATE:

rvm current 
ruby-2.0.0-p353 

rvm gemset list 
gemsets for ruby-2.0.0-p353 (found in /home/deployer/.rvm/gems/ruby-2.0.0-p353) 
=> (default) 
    global 
+0

請輸出'bundle exec ruby​​ -V' – 2014-11-21 14:31:47

+0

ruby​​ 2.0.0p353(2013-11-22 revision 43784)[x86_64-linux]。我編輯了這個問題來添加這個輸出 – user3442206 2014-11-21 14:36:55

+0

ok然後'bundle exec哪個獨角獸' – 2014-11-21 14:40:38

回答

0

晚了一點,但能幫助別人誰遇到同樣的問題。 I'm使用滾動重啓,什麼幫助我是這樣的評論,我有我的config/unicorn.rb文件

# If you roll off old code from your app servers (i.e. the way chef, capistrano, 
    # basically anyone does it) you need to make sure Unicorn is not looking for 
    # the Gemfile it was originally started with. It's really important that after 
    # change you stop/start unicorn after first redeploy. 
    # After that the "before_exec" block will go in memory and 
    # wait for the next deploy! 
    before_exec do |server| 
     ENV['BUNDLE_GEMFILE'] = "#{root}/Gemfile" 
    end 

於是我跑了

/etc/init.d/unicorn-myapp停止

/etc/init。d /獨角獸-myapp開始

和獨角獸拿起了新的紅寶石版本。