I have installed nginx with unicorn on an Ubuntu 12.04 server. Everything works, site, db, unicorn...good. So I'm trying to make sure that after a reboot, nginx and unicorn start up. I have set update-rc.d for my unicorn process, but it doesn't start/work after a reboot. I suspect it has something to do with ubuntu's use of "service" as opposed to "/etc/init.d/unicorn_init "
In other words:
If I execute:
$ /etc/init.d/unicorn_init start
unicorn starts up just fine, no errors.
If I execute:
$ service unicorn_init start
it fails and unicorn does not start.
I've think it has something to do with paths. Ive added environment PATHS to PATH, GEM_PATH, & GEM_HOME, but I still receive the same results
usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find unicorn (>= 0) amongst[bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in `gem'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/unicorn:18:in `<main>'
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- bundler/setup (LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /var/rails/web-app/bin/unicorn:14:in `<main>'
Any help would be greatly appreciated! Thanks
you should use an unicorn wrapper script that will include all the required environment variables:
rvm wrapper 1.9.3 ruby-1.9.3 unicorn
It will generate ruby-1.9.3_unicorn
use this instead of just unicorn in the init script.
You can find more details on wrappers with:
rvm wrapper
In case when work is done via bundler (like capitrano) then generate a wrapper for bundle
:
rvm wrapper 1.9.3 ruby-1.9.3 bundle
and use the full path to the wrapper as displayed by this command:
which ruby-1.9.3_bundle