刚刚通过rbenv将新版本的ruby安装到我的服务器上。
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 install。当我rbenv local 2.3.3
以及rbenv global 2.3.3
,然后gem list
时,我看到了:
'erubis (2.7.0)'
显而易见。也就是说 - 这个宝石绝对存在。
所以我看到它是否与我的其他版本做了一些奇怪的事情。我改为rbenv global 2.2.3
和rbenv local 2.2.3
并做了:
gem install erubis -v 2.7.0
在这之后,现在错误是抱怨另一个不同的宝石,它已经可以在我的2.3.3宝石列表中找到...所以我得出的结论是它肯定只看2.2.3宝石列表,因为添加gem到2.2.3修复了问题。
简单地运行bundle install for 2.2.3不是一个选项 - 我需要仅在我的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
我不知道在这个配置文件中引用了它所引用的ruby版本。因此,我想弄清楚如何让独角兽使用我的新红宝石。
答案 0 :(得分:0)
独角兽使用的rails版本可以在/etc/init.d/unicorn中编辑。我改变了它并且有效。