I have an ruby with sinatra application, and Im trying to run the server with unicorn.
Im using the command:
service unicorn restart
service ngnix restart
and in my logs I get:
/usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'/usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- sinatra (LoadError)
from /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
this problem would be solved running unicorn with bundle exec
how can I do that?
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hey @asb,
At first thanks for the support.
Im running the Ruby on Rails One-Click app,
as you said I tried to change the DAEMON line on the file /etc/default/unicorn to use the bundle exec option.
Now whenever I restart/stop/start my unicorn service I got the following message:
Could not locate Gemfile
I also tried to indicate where the Gemfile location is but not succefull from now…
Do you have any other thoughts in mind?
Thank you!
I solved that issue by changing and adding the ruby version that I was using (2.2.0) into the /etc/defaul/unicorn
# Change parameters below to appropriate values and set CONFIGURED to yes.
CONFIGURED=yes
# Default timeout until child process is killed during server upgrade,
# it has *no* relation to option "timeout" in server's config.rb.
TIMEOUT=60
# Path to your web application, sh'ld be also set in server's config.rb,
# option "working_directory". Rack's config.ru is located here.
APP_ROOT=/home/rails
# Server's config.rb, it's not a rack's config.ru
CONFIG_RB=/home/unicorn/unicorn.conf
# Where to store PID, sh'ld be also set in server's config.rb, option "pid".
PID=/home/unicorn/pids/unicorn.pid
UNICORN_OPTS="-D -c $CONFIG_RB -E production"
PATH=/usr/local/rvm/rubies/ruby-2.1.3/bin:/usr/local/rvm/rubies/ruby-2.0.0-p353/bin:/usr/local/rvm/gems/ruby-2.0.0-p353/bin:/usr/local/rvm/gems/ruby-2.2.0/bin:/home/unicorn/.rvm/bin:/usr/local/sbin:/usr/bin:/bin:/sbin:$
export GEM_HOME=/usr/local/rvm/gems/ruby-2.2.0
export GEM_PATH=/usr/local/rvm/gems/ruby-2.2.0:/usr/local/rvm/gems/ruby-2.2.0
DAEMON=/usr/local/rvm/gems/ruby-2.2.0/bin/unicorn
How did you install and configure unicorn? Are you using the Ruby on Rails One-Click application? If so, unicorn is started and stopped using an init script located in /etc/init.d/unicorn This can be configured in /etc/default/unicorn The default contents looks like:
# Change parameters below to appropriate values and set CONFIGURED to yes.
CONFIGURED=yes
# Default timeout until child process is killed during server upgrade,
# it has *no* relation to option "timeout" in server's config.rb.
TIMEOUT=60
# Path to your web application, sh'ld be also set in server's config.rb,
# option "working_directory". Rack's config.ru is located here.
APP_ROOT=/home/rails
# Server's config.rb, it's not a rack's config.ru
CONFIG_RB=/home/unicorn/unicorn.conf
# Where to store PID, sh'ld be also set in server's config.rb, option "pid".
PID=/home/unicorn/pids/unicorn.pid
UNICORN_OPTS="-D -c $CONFIG_RB -E production"
PATH=/usr/local/rvm/rubies/ruby-2.1.3/bin:/usr/local/rvm/rubies/ruby-2.0.0-p353/bin:/usr/local/rvm/gems/ruby-2.0.0-p353/bin:/home/unicorn/.rvm/bin:/usr/local/sbin:/usr/bin:/bin:/sbin:$
export GEM_HOME=/usr/local/rvm/gems/ruby-2.1.3
export GEM_PATH=/usr/local/rvm/gems/ruby-2.1.3:/usr/local/rvm/gems/ruby-2.1.3
DAEMON=/usr/local/rvm/gems/ruby-2.1.3/bin/unicorn
To use bundler, you would need to update the DAEMON line. It defines the command that will be run. You’ll probably want something like:
DAEMON='/usr/local/rvm/gems/ruby-2.1.3/bin/bundle exec unicorn'
You can use the command which bundle to see the full path of the bundle binary.
For more information about the setup on the Ruby on Rails One-Click app, see this tutorial:
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.