2
我想通過Nginx和Unicorn運行我的Rails應用程序,當我嘗試運行service unicorn start
時,它告訴我我以失敗master failed to start, check stderr log for details
。我的Gemfile指定了ruby 2.0.0,我的ruby版本是2.0.0p353。獨角獸似乎在使用紅寶石2.1.3。有沒有什麼辦法讓獨角獸使用ruby 2.0.0,如果它使用2.1.3默認的話。獨角獸和Gemfile在試圖在數字海洋上運行獨角獸和Nginx時使用的是不同的ruby版本
當我尾巴麒麟日誌:
/usr/local/rvm/gems/ruby-2.1.3/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:294:in `join'
/usr/local/rvm/gems/ruby-2.1.3/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.1.3/bin/unicorn:23:in `load'
/usr/local/rvm/gems/ruby-2.1.3/bin/unicorn:23:in `<main>'
/usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `<main>'
E, [2014-10-31T20:55:57.551794 #15567] ERROR -- : reaped #<Process::Status: pid 30319 exit 1> worker=1
I, [2014-10-31T20:55:57.552041 #15567] INFO -- : worker=1 spawning...
I, [2014-10-31T20:55:57.553188 #30329] INFO -- : worker=0 spawned pid=30329
I, [2014-10-31T20:55:57.560300 #30331] INFO -- : worker=1 spawned pid=30331
I, [2014-10-31T20:55:57.587723 #30329] INFO -- : Refreshing Gem list
I, [2014-10-31T20:55:57.595703 #30331] INFO -- : Refreshing Gem list
E, [2014-10-31T20:55:57.940679 #30325] ERROR -- : Your Ruby version is 2.1.3, but your Gemfile specified 2.0.0 (Bundler::RubyVersionMismatch)
它看起來像錯誤可能從麒麟被位於/usr/local/rvm/gems/ruby-2.1.3/bin/
和我的其他的寶石在/usr/local/rvm/gems/ruby-2.0.0-p353/bin/
被制止。
我unicorn.conf樣子:
worker_processes 4
user "rails"
working_directory "/home/rails"
pid "/home/unicorn/pids/unicorn.pid"
stderr_path "/home/unicorn/log/unicorn.log"
stdout_path "/home/unicorn/log/unicorn.log"
我的獨角獸文件/etc/init.d
樣子:
set -e
NAME=unicorn
DESC="Unicorn web server"
. /lib/lsb/init-functions
if [ -f /etc/default/unicorn ]; then
. /etc/default/unicorn
fi
PID=${PID-/run/unicorn.pid}
run_by_init() {
([ "${previous-}" ] && [ "${runlevel-}" ]) || [ "${runlevel-}" = S ]
}
exit_with_message() {
if ! run_by_init; then
log_action_msg "$1 Not starting."
fi
exit 0
}
check_config() {
if [ $CONFIGURED != "yes" ]; then
exit_with_message "Unicorn is not configured (see /etc/default/unicorn)."
fi
}
check_app_root() {
if ! [ -d $APP_ROOT ]; then
exit_with_message "Application directory $APP_ROOT is not exist."
fi
}
set -u
```
And the start function in that file:
```
start)
check_config
check_app_root
log_daemon_msg "Starting $DESC" $NAME || true
if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $UNICORN_OPTS; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
其次是像重新啓動其他命令,停止等。
而且我的Gemfile:
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0'
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.4.0'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails'
gem 'jbuilder', '1.5.3'
gem 'bootstrap-sass', '3.1.1.0'
gem 'figaro'
gem 'rolify'
gem 'simple_form'
gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'rails_12factor'
gem 'pg'
gem 'notes-cli'
gem 'twitter-typeahead-rails'
gem 'gon'
group :development do
gem 'better_errors'
gem 'binding_of_caller', :platforms=>[:mri_19, :mri_20, :rbx]
gem 'quiet_assets'
gem 'rails_layout'
gem 'mailcatcher'
gem 'rails-erd'
gem 'annotate'
end
group :development, :test do
gem 'factory_girl_rails'
gem 'rspec-rails'
gem 'faker'
gem 'pry'
gem 'rb-fsevent'
gem 'guard-rspec'
gem 'terminal-notifier-guard'
end
group :test do
gem 'capybara', '2.4.3'
gem 'database_cleaner'
gem 'email_spec'
end
我會很感激的任何幫助。我是Digital Ocean,Unicorn和Nginx的新手,我的唯一經歷 在「部署」中使用Heroku。
我有完全相同的問題! – 2015-04-16 08:14:43