-
Notifications
You must be signed in to change notification settings - Fork 726
RVM Notes
I'm not sure where to put this, but I wanted to share this tidbit of info.
I was having an issue where I would see all these hanging
/bin/bash
processes calling runner and rake that were being fired off by cron. Turns out my.rvmrc
file in my app folder was causing the problem. Rvm by default will prompt to trust or not trust the file. This causes bash to hang. The solution I used was to disable the prompt by adding this line to my user rvm file in~/.rvmrc
rvm_trust_rvmrcs_flag=1
This tells rvm to trust all rvmrc files. This is documented here: http://wayneeseguin.beginrescueend.com/2010/08/22/ruby-environment-version-manager-rvm-1-0-0/
https://github.com/javan/whenever/issues#issue/110
The reason that the processes are hanging is because whenever generates crontab entries that first cd into the release path. So /u/apps/my_app/releases/201302121406 instead of /u/apps/my_app/current. By cd'ing into the release path RVM believes the .rvmrc file is unknown (even though we both know it really isn't). And since it's unknown, RVM is going to prompt you to trust it. At which point it hangs.
If you don't want to set rvm_trust_rvmrcs_flag=1
the following works for me for a Rails3/bundler/capistrano/multi-stage application.
-
Make
config/deploy.rb
look like this:set :whenever_environment, defer { stage } set :whenever_identifier, defer { "#{application}_#{stage}" } set :whenever_command, "bundle exec whenever" set :whenever_variables, defer { "'environment=#{rails_env}¤t_path=#{current_path}'" } require 'whenever/capistrano'
-
Make
config/schedule.rb
look like this:job_type :rake, "{ cd #{@current_path} > /dev/null; } && RAILS_ENV=:environment bundle exec rake :task --silent :output" job_type :script, "{ cd #{@current_path} > /dev/null; } && RAILS_ENV=:environment bundle exec script/:task :output" job_type :runner, "{ cd #{@current_path} > /dev/null; } && RAILS_ENV=:environment bundle exec rails runner ':task' :output"
The { cd #{@current_path} > /dev/null; }
bit will result in cd'ing to to the 'current' direction of your application. The braces and redirection are there to suppress RVM's output of "using ruby@gemset" notification.