Whenever gem executing from within Capistrano on new server

625 Views Asked by At

I have a Rails 3.2.14 legacy app in production and it's working fine. I'm migrating this app to a new server and will migrate the database from the production at time of switch over. So far I have the app spun up and it's working (for the most part). But when I use Capistrano to deploy to that server, the whenever gem doesn't seem to run (though it does on the original production server and updates crontab).

I'm using whenever gem 0.7.3, capistrano 2.12.0, Ruby 1.9.3p194 to keep the environment identical.

Here's what my deploy.rb in Capistrano looks like (and works on the old server to execute whenever:

require "bundler/capistrano"
set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"

server "72.14.181.80", :web, :app, :db, primary: true

set :application, "appname"
set :user, "deploy"
set :deploy_to, "/home/#{user}/#{application}"
set :use_sudo, false
set :rails_env, "production"


set :scm, "git"
set :repository, "[email protected]:username/#{application}.git"
set :branch, "master"


default_run_options[:pty] = true
ssh_options[:forward_agent] = true

after "deploy", "deploy:cleanup" # keep only the last 5 releases
after "deploy:update", "gps_listener:restart"

namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
  desc "reload the database with seed data"
  task :seed do
    run "cd #{current_path}; bundle exec rake db:seed RAILS_ENV=#{rails_env}"
  end
end

namespace :gps_listener do
  task :start do
    run "#{sudo} start app-gps"
  end

  task :stop do
    run "#{sudo} stop app-gps"
  end

  task :restart do
    run "#{sudo} stop app-gps && sleep 1 && #{sudo} start app-gps"
  end
end

task :after_update_code do
  run "ln -nfs #{deploy_to}/shared/config/database.yml #{release_path}/config/database.yml"
  run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec rake gps:listen"
end

What's interesting is, when I deploy to our old production server whenever will execute and update the crontab with the rake tasks. But if I switch the IP in deploy.rb and deploy to our new server it will not execute and the Capistrano output doesn't show anything fishy that I can see.

Is there somewhere I can debug this? I want to keep the Capistrano/Rails configuration the same for both servers. Just not sure what the problem is. Maybe I'm overlooking something.

It should also be noted, that when I'm on the new server in the app/current directory I can run the following and it will update my crontab properly:

RAILS_ENV=production bundle exec whenever -w
0

There are 0 best solutions below