9z0b3t1c / capistrano-resque

Capistrano integration for Resque

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

resque:* produces no output

eidge opened this issue · comments

In my deploy.rb I've got:

role :resque_worker, fetch(:stage_url)            

set :workers, { 'interaction_scheduler' => 1, 'alarm_raiser' => 1 }   
set :resque_environment_task, true

but cap stage resque:stop for instace produces no output when I was expecting it to produce:

No pid files found

No workers are started on resque:start either.

I'm using capistrano 3.2.1.

What do you see if you add set :log_level, :debug to your deploy.rb file?

Also, did you already have :log_level set to something else, maybe :error?

No output whatsoever, if I run capistrano with the trace option, then I still get no output:

** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rbenv:validate (first_time)
** Execute rbenv:validate
DEBUG[27079c9a] Running /usr/bin/env [ ! -d ~/.rbenv/versions/2.1.1 ] on dev-org.nourishcare.co.uk
DEBUG[27079c9a] Command: [ ! -d ~/.rbenv/versions/2.1.1 ]
DEBUG[27079c9a] Finished in 1.566 seconds with exit status 0 (success).
** Invoke rbenv:map_bins (first_time)
** Execute rbenv:map_bins
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke resque:start (first_time)
** Execute resque:start

I've tried defining the recipes locally and it never gets past this:

on roles(*workers_roles) do

Ah, ok, I think this is because you're assigning fetch(:stage_url) to your resque_worker role; I assume that if you hardcode a server address in there instead, it works fine.

I'll play around with this to see if it's an issue on our end or on Capistrano's end and see what we can do. Thanks for reporting this!

Actually, where is stage_url being set? As far as I can tell, this is not a Capistrano thing, and when I try this on my test app, stage_url is blank (so cap-resque doesn't know which server to connect to as a result.

I can't find any references to stage_url anywhere in the Capistrano repo.

I'm defining it myself inside each stage. I'll try hardcoding it to see if
it works!

Thanks for the prompt response!

Hugo Ribeira

Jack of All Trades at *intoCros http://intocross.coms
http://intocross.com *
Tel: +351 910982209 http://910982209 * LinkedIn
http://pt.linkedin.com/pub/hugo-ribeira/45/295/536/ * GitHub
https://github.com/eidge
Universidade de Coimbra

2014-08-04 15:23 GMT+01:00 Dylan Markow notifications@github.com:

Actually, where is stage_url being set? As far as I can tell, this is not
a Capistrano thing, and when I try this on my test app, stage_url is
blank (so cap-resque doesn't know which server to connect to as a result.

I can't find any references to stage_url anywhere in the Capistrano repo.


Reply to this email directly or view it on GitHub
#86 (comment)
.

So you're doing something like this?

set :stage_url, "foo@bar.com"
role :resque_worker, fetch(:stage_url)

I'm surprised that doesn't work then, I might play around with that some more just for my own curiousity. In the mean time, hopefully hardcoding the URL will work for you.

exactly: set :stage_url, 'subdomain.mydomain.com'.

Hardcoding works fine, but I need to define it as a variable as we have 3
different stages: [dev, production, demo]

I can't really understand why it doesn't work!

Hugo Ribeira

Jack of All Trades at *intoCros http://intocross.coms
http://intocross.com *
Tel: +351 910982209 http://910982209 * LinkedIn
http://pt.linkedin.com/pub/hugo-ribeira/45/295/536/ * GitHub
https://github.com/eidge
Universidade de Coimbra

2014-08-04 16:21 GMT+01:00 Dylan Markow notifications@github.com:

So you're doing something like this?

set :stage_url, foo@bar.com
role :resque_worker, fetch(:stage_url)

I'm surprised that doesn't work then, I might play around with that some
more just for my own curiousity. In the mean time, hopefully hardcoding the
URL will work for you.


Reply to this email directly or view it on GitHub
#86 (comment)
.

So :stage_url is defined in (staging|demo|production).rb and is nil in
deploy.rb. (p prints nil if in the deploy.rb or the correct value if inside
one of the stages)

if :resque_worker is defined in the stage files it fails.

It seems like a capistrano problem, because it should be defined in
deploy.rb
It seems like a capistrano-resque problem because defining :resque_worker
in the stage files should work.

Hugo Ribeira

Jack of All Trades at *intoCros http://intocross.coms
http://intocross.com *
Tel: +351 910982209 http://910982209 * LinkedIn
http://pt.linkedin.com/pub/hugo-ribeira/45/295/536/ * GitHub
https://github.com/eidge
Universidade de Coimbra

2014-08-04 16:40 GMT+01:00 Hugo Ribeira hugoribeira@gmail.com:

exactly: set :stage_url, 'subdomain.mydomain.com'.

Hardcoding works fine, but I need to define it as a variable as we have 3
different stages: [dev, production, demo]

I can't really understand why it doesn't work!

Hugo Ribeira

Jack of All Trades at *intoCros http://intocross.coms
http://intocross.com *
Tel: +351 910982209 http://910982209 * LinkedIn
http://pt.linkedin.com/pub/hugo-ribeira/45/295/536/ * GitHub
https://github.com/eidge
Universidade de Coimbra

2014-08-04 16:21 GMT+01:00 Dylan Markow notifications@github.com:

So you're doing something like this?

set :stage_url, foo@bar.com
role :resque_worker, fetch(:stage_url)

I'm surprised that doesn't work then, I might play around with that some
more just for my own curiousity. In the mean time, hopefully hardcoding the
URL will work for you.


Reply to this email directly or view it on GitHub
#86 (comment)
.

It might be a me (or documentation) problem as well.

server fetch(:stage_url), user: 'deployer', roles: %w(web app db **resque_worker**), primary: true

solves it.

So were you defining stage_url in each of your 3 stages, then just having a single set :resque_worker, fetch(:stage_url) in your config/deploy.rb file? Or did you have that identical line in each of your 3 stages?

Also, it makes sense that variables you set in a stage file aren't available in config/deploy.rb, as capistrano loads deploy.rb before loading the stage file:

# lib/capistrano/setup.rb

namespace :load do
  task :defaults do
    load 'capistrano/defaults.rb'
  end
end

stages.each do |stage|
  Rake::Task.define_task(stage) do
    set(:stage, stage.to_sym)

    invoke 'load:defaults'
    load deploy_config_path
    load stage_config_path.join("#{stage}.rb")
    load "capistrano/#{fetch(:scm)}.rb"
    I18n.locale = fetch(:locale, :en)
    configure_backend
  end
end

​Different stage_url for each stage.
Single resque_worker line.

stage_url is nil in the deploy.rb file scope. (odd as I see it)

Eitheir way I've looked into it further, it's Capistrano fault be it a bug
or design. You might want to add some documentation to explain how to setup
multistage workers though.​

Hugo Ribeira

Jack of All Trades at *intoCros http://intocross.coms
http://intocross.com *
Tel: +351 910982209 http://910982209 * LinkedIn
http://pt.linkedin.com/pub/hugo-ribeira/45/295/536/ * GitHub
https://github.com/eidge
Universidade de Coimbra

2014-08-04 16:52 GMT+01:00 Dylan Markow notifications@github.com:

So were you defining stage_url in each of your 3 stages, then just having
a single set :resque_worker, fetch(:stage_url) in your config/deploy.rb
file? Or did you have that identical line in each of your 3 stages?


Reply to this email directly or view it on GitHub
#86 (comment)
.

So, for now, the answer is to make sure you're setting resque_worker inside your stage file, not deploy.rb.

I will update the README to reflect this. Thanks for providing all the additional info.

Yes, exactly.

There are two ways you can do it supporting multi stage:

role :resque_worker, DOMAIN
role :other_roles
(...)
server DOMAIN

Your role call must happen before the server call.

Or defining it directly in the server call:

server DOMAIN, roles: %w(app db resque_worker)

I prefer the latest as it's shorter.

If you're defining more than a stage, then you need to use one of the above
methods. Defining it in deploy.rb will fail.

Hugo Ribeira

Jack of All Trades at *intoCros http://intocross.coms
http://intocross.com *
Tel: +351 910982209 http://910982209 * LinkedIn
http://pt.linkedin.com/pub/hugo-ribeira/45/295/536/ * GitHub
https://github.com/eidge
Universidade de Coimbra

2014-08-04 16:57 GMT+01:00 Dylan Markow notifications@github.com:

So, for now, the answer is to make sure you're setting resque_worker
inside your stage file, not deploy.rb.

I will update the README to reflect this. Thanks for providing all the
additional info.


Reply to this email directly or view it on GitHub
#86 (comment)
.