capistrano 'executing bundle install' not completing - ruby-on-rails

I'm following the instructions of Ryan Bates' Deploy to a VPS Railscast to deploy my app to an ubuntu cloud server on Digital Ocean. After I run cap deploy:cold, a few different commands are executed successfully, but then when it gets to 'executing bundle:install' it stays in 'executing command' mode for a very long time without throwing any kind of error or completing, like this
command finished in 171ms
* 2013-06-27 12:57:07 executing `bundle:install'
* executing "cd /home/michaelj/apps/qbruby2/releases/20130627195707 && bundle install --gemfile /home/michaelj/apps/qbruby2/releases/20130627195707/Gemfile --path /home/michaelj/apps/qbruby2/shared/bundle --deployment --quiet --without development test"
servers: ["192.xxx.xxx.xxx"]
[192.241.129.33] executing command
I looked at some other people's deployments (on Stackoverflow) and saw that this command usually completes in a matter of milliseconds. My whole gemfile has less than 20 gems (i.e. the standard gems plus a few extras), yet deployment has been paused here for more than 20 minutes.
Can you suggest what I might do?

The first step in troubleshooting these issues, is ensuring you can run the commands remotely.
Thankfully, capistrano outputs the commands it's trying to execute. Then you can do copy/paste over to the server.
In my experience, i've seen the ssh server terminating ssh sessions for long running processes. (that is migrations or bundle install for example) For those cases, there are a few options (modifying sshd_config on the server has worked for me)
add these lines to /etc/ssh/sshd_config
ClientAliveInterval 30
ClientAliveCountMax 5

Related

Updated code on production server, but no changes on browser

I just deployed, and everything ran fine without errors. Previously it was running fine too. The code in the production is updated in the current version, but when I browse using a new browser, it was using old code.
I have tried restarting unicorn, nginx, but no problem whatsoever. There's no error message.
I tried it on staging environment, everything is good. Just doesn't work on production.
I tried to redeploy too. Nothing changed.
UPDATE 1
Not sure what happened, but after restarting the entire server it went fine again. Anyone knows why?
try this out :
cd /opt/nginx/cache
and do rm -rf *
and restart the server again
let me know if this helps
This worked for me:
cd <project dir>
rm -rf tmp/cache
apache2ctl restart
My situation, no changes in my controllers, or helpers were being reflected in production. This fixed it.
Also, make sure you are not running Spring in production.
ps aux | grep -i spring
killall spring
spring stop
Refer to 'Deployment', on the github
You must not install Spring on your production environment. To prevent
it from being installed, provide the --without development test
argument to the bundle install command which is used to install gems
on your production machines:
$ bundle install --without development test

Ruby on Rails fails on bundle install when using capistrano

I have not much knowledge of Ruby. I have to host a Ruby website. When I make deploy setup and check, is everything ok. But when I cap deploy I get the following error.
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/lpavisit/releases/20131009211837; true"
servers: ["x.xx.xx.xxx"]
[5.56.61.183] executing command
command finished in 209ms
failed: "sh -c 'cd /var/www/lpavisit/releases/20131009211837 && bundle install --without development test'" on x.xx.xx.xxx
Thanks!!
Setting up a Capistrano-based deploy system is a bit complex. You might want to give Heroku a try until you're more familiar with Ruby. But to continue with Capistrano, first ask it if it has everything it needs to deploy:
$ cap deploy:check
You want to see it say, You appear to have all necessary dependencies installed. Yours probably won't. In that case, you should look for a good capistrano book or online tutorial.

Rubber fails during create_staging Bundler::GemfileNotFound ec2

This is my first time deploying an app to an ec2 instance. It seems most of the process worked but eventually the deploy failed with the following error:
failed: "/bin/bash -l -c 'cd /mnt/depot-production/releases/20130312030226 && bundle install --gemfile /mnt/depot-production/releases/20130312030226/Gemfile --path /mnt/depot-production/shared/bundle --deployment --quiet --without development test staging'" on production.foo.com
I logged into my server and went to the directory and tried to execute the command. The following error was displayed:
Bundler::GemfileNotFound
When I list the contents of the directory, it shows a gemfile. Just could use some help in determining why it is not found and how to fix it.
I'm also not exactly sure how to proceed? I would like to simply fix the error and continue on with the instance that was created but not sure what steps all need to be executed.

How to make crontab use the correct rake and refer to gems in vendor/bundle

I would like my cron job, which calls a rake task, to use the gems installed in either [rails_app]/vendor/bundle or [rails_app]/vendor/cache. Currently, my system gems are out-of-date, but I cannot update them for various reasons beyond my control.
I tried using bundle exec, but this does not seem to work. The error I get is
usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/spec_set.rb:88:in 'materialize': Could not find rake-0.9.2.2 in any of the sources (Bundler::GemNotFound)
I believe this is because my system's rake is out-of-date. I tried using bundle exec rake _0.9.2.2_ [my_task] in the cron job, but the same error appeared
I tried the whenever gem; this produced the exact error.
So I guess I have two questions:
How do I make cron use the correct rake version? And
How do I point it to gems already in vendor/bundle or vendor/cache?
Note that the site works when deployed in Phusion Passenger.
While hunting a solution for the same problem I found this Thread with several tips.
the quick & easy way for me was to just run the cron command as login shell - like this:
* * * * * /bin/bash -l -c 'bundle exec rake _0.9.2.2_ [my_task]' 2>&1
the ending 2>&1 is just to be sure to receive errors in cron log. also see man bash for further info!

rails deployment with jenkins extremly slow

I use Jenkins to test and deploy a Rails 3 application. It fetches the source from a SVN repo, then runs:
bundle install --deployment
bundle exec rake assets:precompile
rake spec
The process is very slow, it takes more than an hour (!), when locally bundle install --deployment takes 3 minutes. I run ps aux on the server during the bundling process and it doesn't seem to be overloaded. What could be the cause of such strange behaviour? How could I fix it?
This may have to do with running Jenkins in the background (and/or as a service). Try running it in the foreground with java -jar jenkins.war an see if it helps.

Resources