2017-09-22 95 views
0

刚刚完成通过rbenv在我的服务器上安装新版本的ruby。独角兽没有使用rbenv版本或rails -v版本

rbenv versions回报:

system 
2.2.3 
* 2.3.3 (set by /opt/pesto/current/config/.ruby-version) 

我试图重新启动我的麒麟服务(sudo service unicorn restart):

Couldn't restart. 

无奈之下,我尝试启动(sudo service unicorn start):

Could not find erubis-2.7.0 in any of the sources 
Run `bundle install` to install missing gems. 

我已经运行了bundle安装。当我做rbenv local 2.3.3以及rbenv global 2.3.3,然后gem list,我看到:

'erubis (2.7.0)' 

在众目睽睽下。这就是说 - 这个宝石绝对在那里。

所以我看到它是否与我的其他版本做了一些奇怪的事情。我改rbenv global 2.2.3rbenv local 2.2.3,做:

gem install erubis -v 2.7.0 

这样做之后,现在的错误是抱怨另一种不同的宝石,也已经在我的2.3.3宝石列表中找到......所以我的结论它绝对只看2.2.3宝石列表,因为在2.2.3中加入宝石可以解决这个问题。

简单地运行2.2.3的bundle install不是一个选项 - 我需要的依赖项仅在我的2.3.3发行版中可用。我真正想要的是独角兽只提及2.3.3中的可用内容,并放弃查看2.2.3以及那里可用的宝石。

这里是我的unicorn.rb:

app_path = File.expand_path(File.dirname(__FILE__) + '/..') 
# Set the working application directory 
# working_directory "/path/to/your/app" 
working_directory app_path 

before_exec do |server| 
    ENV['BUNDLE_GEMFILE'] = "#{root}/Gemfile" 
end 


# Set the location of the unicorn pid file. This should match what we 
put in the 
# unicorn init script later. 
pid (ENV['UNICORN_PID_PATH'] || "#{app_path}/tmp/") + 'unicorn.pid' 

# You should define your stderr and stdout here. If you don't, stderr 
defaults 
# to /dev/null and you'll lose any error logging when in daemon mode. 
stderr_path(app_path + '/log/unicorn.log') unless ENV['RAILS_ENV'] == 
'development' 
stdout_path(app_path + '/log/unicorn.log') unless ENV['RAILS_ENV'] == 
'development' 

# Unicorn socket 
listen('127.0.0.1:3000', backlog: 64, :tcp_nopush => true) if 
ENV['RAILS_ENV'] == 'development' 
list en(app_path + '/tmp/unicorn.sock', backlog: 64) unless 
ENV['RAILS_ENV'] == 'development' 
listen(8080, :tcp_nopush => true) unless ENV['RAILS_ENV'] == 
'development' 

# Number of processes 
# worker_processes 4 
worker_processes (ENV['RAILS_ENV'] == 'production' ? 16 : 1) 

# Time-out 
timeout 300 

# Load the app up before forking. 
preload_app true 

# Garbage collection settings. 
GC.respond_to?(:copy_on_write_friendly=) && 
    GC.copy_on_write_friendly = true 

# If using ActiveRecord, disconnect (from the database) before 
forking. 
before_fork do |server, worker| 
    defined?(ActiveRecord::Base) && 
    ActiveRecord::Base.connection.disconnect! 
end 

# After forking, restore your ActiveRecord connection. 
after_fork do |server, worker| 
    defined?(ActiveRecord::Base) && 
    ActiveRecord::Base.establish_connection 
end 

我看不出它是指红宝石版本在此配置文件中被引用。因此,我在计算如何让独角兽使用我的新红宝石方面存在一些争议。

回答

0

独角兽使用的rails版本可以在/etc/init.d/unicorn中编辑。我改变了它,它工作。