collectiveidea / delayed_job

Database based asynchronous priority queue system -- Extracted from Shopify
http://groups.google.com/group/delayed_job
MIT License
4.82k stars 954 forks source link

Capistrano 3 PID problem? #651

Open wanabewired opened 10 years ago

wanabewired commented 10 years ago

Hi,

I'm on:

I have implemented the deploy code as per the rake and deploy code at: https://github.com/collectiveidea/delayed_job/wiki/Delayed-Job-tasks-for-Capistrano-3

When I run that code, I get the following error:

undefined method `verbosity' for "/usr/bin/env delayed_job:restart\n":String
/Users/username/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/formatters/pretty.rb:10:in `write'
/Users/username/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/printer.rb:14:in `block in execute'
/Users/username/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/printer.rb:13:in `tap'
/Users/username/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/printer.rb:13:in `execute'
config/deploy.rb:49:in `block (4 levels) in <top (required)>'
/Users/username/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/abstract.rb:81:in `within'
config/deploy.rb:48:in `block (3 levels) in <top (required)>'
/Users/username/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/username/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/username/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/runners/sequential.rb:9:in `block in execute'
/Users/username/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/runners/sequential.rb:8:in `each'
/Users/username/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/runners/sequential.rb:8:in `execute'
/Users/username/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/coordinator.rb:21:in `each'
/Users/username/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/dsl.rb:8:in `on'
config/deploy.rb:47:in `block (2 levels) in <top (required)>'
/Users/username/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/dsl/task_enhancements.rb:12:in `block in after'
/Users/username/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/dsl.rb:14:in `invoke'
/Users/username/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/tasks/framework.rake:65:in `block (2 levels) in <top (required)>'
/Users/username/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/tasks/framework.rake:64:in `each'
/Users/username/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/tasks/framework.rake:64:in `block in <top (required)>'
/Users/username/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/application.rb:15:in `run'
/Users/username/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/bin/cap:3:in `<top (required)>'
/Users/username/.rvm/gems/ruby-2.1.0/bin/cap:23:in `load'
/Users/username/.rvm/gems/ruby-2.1.0/bin/cap:23:in `<main>'
Tasks: TOP => deploy:restart
(See full trace by running task with --trace)
The deploy has failed with an error: #<NoMethodError: undefined method `verbosity' for "/usr/bin/env delayed_job:restart\n":String>

I'm having similar problems to this chap: https://github.com/rvm/rvm1-capistrano3/issues/26 who swapped out the line in the deploy restart task to this:

desc 'Restart application'
task :restart do
  on roles(:app), in: :sequence, wait: 5 do
    within release_path do
      execute :mkdir, "-p", "tmp/pids"
      execute :bundle, :exec, :'bin/delayed_job', fetch(:delayed_job_args, ""), :restart
    end
  end
end

Which gives me the following:

 INFO [3c24696f] Running ~/.rvm/bin/rvm default do bundle exec bin/delayed_job -n 2 restart on bctools
DEBUG [3c24696f] Command: cd /var/rails/bctoolsapp/releases/20140422082857 && ~/.rvm/bin/rvm default do bundle exec bin/delayed_job -n 2 restart
DEBUG [3c24696f]    Warning: no instances running. Starting...
DEBUG [3c24696f]    Warning: no instances running. Starting...
 INFO [3c24696f] Finished in 4.032 seconds with exit status 0 (successful).

The problem is, each time I run the deploy code, I get the same output and when running ps, it shows it isn't actually finding the running tasks and is instead just starting up two new ones each time.

username      3002  0.3  3.3 941484 93492 ?        Sl   10:20   0:00 delayed_job.0                    
username      3008  0.3  3.3 941484 93492 ?        Sl   10:20   0:00 delayed_job.1                    
username      4703  2.1  3.3 943576 95648 ?        Sl   10:21   0:00 delayed_job.0                    
username      4709  2.0  3.3 943584 95652 ?        Sl   10:21   0:00 delayed_job.1                    

Is this something anyone else has come across before? If so, I'd appreciate it if you could point me in the direction of a fix.

Thanks in advance.

khacluan commented 9 years ago

execute :bundle, :exec, "command" :+1: