ruby-on-rails-3.2resquecapistrano3ruby-2.1

Resque not starting after cap:deploy in Rails 3 app


I have recently added capistrano to my test rails app to understand the working of capistrano. I am able to deploy the app using it but my resque commands are not getting executed.

It does not show any error but there is no resque worker started. I have even checked by logging into the server. I have tried changing the after hooks in capistrano from deploy:restart to deploy:published.

deploy.rb

lock '3.6.1'

set :application, 'test_app'
set :repo_url, 'sample_url.git'
set :resque_log_file, "log/resque.log"

set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')

config/deploy/capistrano_test.rb

set :use_sudo, true

server 'ruby2', user: 'ubuntu', roles: %w{web app db}
set :ssh_options, { forward_agent: true }

set :branch, 'capistrano_test'
set :deploy_to, '/var/www/test_cap'

role :resque_worker, 'ruby2'

set :workers, { 
    ruby2: {"file_serve"=>1,"*" => 1,"tasks_queue"=>1,"sunspot"=>1} 
}

after "deploy:restart", "resque:restart"

Capfile

require "capistrano/setup"

require "capistrano/deploy"

require "capistrano/rvm"
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/rake'
require "capistrano-resque"

Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

Logs

** Invoke deploy:published (first_time)
** Execute deploy:published
** Invoke resque:restart (first_time)
** Execute resque:restart
** Invoke resque:stop (first_time)
** Execute resque:stop
** Invoke resque:start (first_time)
** Execute resque:start
** Invoke deploy:finishing (first_time)
** Execute deploy:finishing
** Invoke deploy:cleanup (first_time)
** Execute deploy:cleanup
01:23 deploy:cleanup
      Keeping 5 of 6 deployed releases on ruby2
      01 rm -rf /var/www/test_cap/releases/20161111045128
    ✔ 01 ubuntu@ruby2 3.018s
** Invoke deploy:finished (first_time)
** Execute deploy:finished
** Invoke deploy:log_revision (first_time)
** Execute deploy:log_revision
01:28 deploy:log_revision
      01 echo "Branch capistrano_test (at af938c9c04998d97176886462eac94701292bcfd) deployed as release 20161114030844 by venkat" >> /var/www/test_ca…
    ✔ 01 ubuntu@ruby2 1.909s

resque:restart is getting called but nothing happens.


Solution

  • I was able to run resque by changing the following code:

    set :workers, { 
        ruby2: {"file_serve"=>1,"*" => 1,"tasks_queue"=>1,"sunspot"=>1} 
    }
    

    to this:

    set :workers, { "file_serve"=>1,"*" => 1,"tasks_queue"=>1,"sunspot"=>1}
    

    But I still do not why the previous code did not run, as it is mentioned in the documentation.