Giter Club home page Giter Club logo

capistrano-resque's Introduction

Capistrano Resque

Basic tasks for putting some Resque in your Cap. This should be fully compatible with both Capistrano 2.x and 3.x, but if you run into any issues please report them.

At this time, we are only targeting Resque 1.x; the 2.0/master branch is still a work-in-progress without a published gem.

In your Gemfile:

gem "capistrano-resque", "~> 0.2.2", require: false

In lib/tasks:

You'll need to make sure your app is set to include Resque's rake tasks. Per the Resque 1.x README, you'll need to add require 'resque/tasks' somewhere under the lib/tasks directory (e.g. in a lib/tasks/resque.rake file).

In your Capfile:

Put this line after any of capistrano's own require/load statements (specifically load 'deploy' for Cap v2):

require "capistrano-resque"

Note: You must tell Bundler not to automatically require the file (by using require: false), otherwise the gem will try to load the Capistrano tasks outside of the context of running the cap command (e.g. running rails console).

In your deploy.rb:

# Specify the server that Resque will be deployed on. If you are using Cap v3
# and have multiple stages with different Resque requirements for each, then
# these __must__ be set inside of the applicable config/deploy/... stage files
# instead of config/deploy.rb:
role :resque_worker, "app_domain"
role :resque_scheduler, "app_domain"

set :workers, { "my_queue_name" => 2 }

# We default to storing PID files in a tmp/pids folder in your shared path, but
# you can customize it here (make sure to use a full path). The path will be
# created before starting workers if it doesn't already exist.
# set :resque_pid_path, -> { File.join(shared_path, 'tmp', 'pids') }

# Uncomment this line if your workers need access to the Rails environment:
# set :resque_environment_task, true

You can also specify multiple queues and the number of workers for each queue:

set :workers, { "archive" => 1, "mailing" => 3, "search_index, cache_warming" => 1 }

The above will start five workers in total:

  • one listening on the archive queue
  • one listening on the search_index, cache_warming queue
  • three listening on the mailing queue

If you need to pass arbitrary data (like other non-standard environment variables) to the "start" command, you can specify:

set :resque_extra_env, "SEARCH_SERVER=172.18.0.52"

This can be useful for customizing Resque tasks in complex server environments.

Multiple Servers/Roles

You can also start up workers on multiple servers/roles:

role :worker_server_A,  <server-ip-A>
role :worker_servers_B_and_C,  [<server-ip-B>, <server-ip-C>]

set :workers, {
  worker_server_A: {
    "archive" => 1,
    "mailing" => 1
  },
  worker_servers_B_and_C: {
    "search_index" => 1,
  }
}

The above will start four workers in total:

  • one archive on Server A
  • one mailing on Server A
  • one search_index on Server B
  • one search_index on Server C

Rails Environment

With Rails, Resque requires loading the Rails environment task to have access to your models, etc. (e.g. QUEUE=* rake environment resque:work). However, Resque is often used without Rails (and even if you are using Rails, you may not need/want to load the Rails environment). As such, the environment task is not automatically included.

If you would like to load the environment task automatically, add this to your deploy.rb:

set :resque_environment_task, true

If you would like your workers to use a different Rails environment than your actual Rails app:

set :resque_rails_env, "my_resque_env"

The tasks

Running cap -vT | grep resque should give you...

➔ cap -vT | grep resque
cap resque:status    # Check workers status
cap resque:start     # Start Resque workers
cap resque:stop      # Quit running Resque workers
cap resque:restart   # Restart running Resque workers
cap resque:scheduler:restart #
cap resque:scheduler:start   # Starts Resque Scheduler with default configs
cap resque:scheduler:stop    # Stops Resque Scheduler

Restart on deployment

To restart you workers automatically when cap deploy:restart is executed add the following line to your deploy.rb:

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

Logging

Backgrounding and logging are current sticking points. I'm using the HEAD of resque's 1-x-stable branch for the 0.0.8 release because it has some new logging functions not yet slated for a resque release.

In your Gemfile, you will need to specify:

gem 'resque', :git => 'git://github.com/resque/resque.git', :branch => '1-x-stable'

Also, you will need to include:

Resque.logger = Logger.new("new_resque_log_file")

...somewhere sensible, such as in your resque.rake, to achieve logging.

The chatter on: https://github.com/defunkt/resque/pull/450 gives more information. If using HEAD of this resque branch doesn't work for you, then pin to v0.0.7 of this project.

Redirecting output

Due to issues in the way Resque 1.x handles background processes, we automatically redirect stderr and stdout to /dev/null.

If you'd like to capture this output instead, just specify a log file:

set :resque_log_file, "log/resque.log"

You can also disable the VERBOSE option to reduce the amount of log output:

set :resque_verbose, false

Limitations

Starting workers is done concurrently via Capistrano and you are limited by ssh connections limit on your server (default limit is 10)

To to use more workers, please change your sshd configuration (/etc/ssh/sshd_config)

MaxStartups 100

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. If possible, make sure your changes apply to both the Capistrano v2 and v3 code (capistrano_integration.rb is v2, capistrano-resque.rake is v3)
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

License

Please see the included LICENSE file.

capistrano-resque's People

Contributors

andrzejsliwa avatar aprimadi avatar ariejan avatar arturtr avatar athal7 avatar benweint avatar dhanson358 avatar dmarkow avatar dtaniwaki avatar erkattak avatar freemanoid avatar jonknapp avatar konalegi avatar larsthegeek avatar mkdynamic avatar pavels avatar toqoz avatar tylerrick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

capistrano-resque's Issues

Sometimes resque:scheduler:restart doesnt kill active process, instead it spawns new one

When running cap develop resque:scheduler:restart, sometimes it doesnt kill active process from pid, instead it spawns new one. Server is running on ubuntu 14

capistrano - 3.4.0
capistrano-resque - 0.2.2
resque - 1.25.2

ps aux | grep resque-scheduler-4.0.0
root      6137  0.0  0.3 1063524 119632 ?      Sl   Dec16   0:10 resque-scheduler-4.0.0[server_production]: Processing Delayed Items
root      9200  0.0  0.3 1055524 111196 ?      Sl   02:34   0:00 resque-scheduler-4.0.0[server_develop]: Schedules Loaded
root     13567  0.0  0.3 1055560 111424 ?      Sl   02:35   0:00 resque-scheduler-4.0.0[server_develop]: Schedules Loaded
root     18716  0.0  0.3 1054792 112568 ?      Sl   02:36   0:00 resque-scheduler-4.0.0[server_develop]: Schedules Loaded
root     24277  0.0  0.3 1055884 111696 ?      Sl   02:31   0:00 resque-scheduler-4.0.0[server_develop]: Schedules Loaded
root     24977  0.0  0.3 1055080 110952 ?      Sl   02:37   0:00 resque-scheduler-4.0.0[server_develop]: Schedules Loaded
root     25345  0.0  0.0  11848   932 pts/4    S+   02:37   0:00 grep --color=auto resque-scheduler-4.0.0

Bump version for resque_extra_env

Hi,

For the moment, adding gem 'capistrano-resque', '~> 0.2.2', require: false to the Gemfile downloads a version without the resque_extra_env parameter.
Could you bump the gem version so we can have it?
Thanks :)

Example usage with capistrano v3.1?

Anyone have a gist or something showing examples of usage with capistrano 3? '
Here is my snippet from deploy.rb

namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      execute :touch, release_path.join("tmp/restart.txt")
    end
  end

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      within release_path do
      end
    end
  end

  after :finishing, 'deploy:cleanup'
  after :restart, 'resque:restart'
end

But I don't see any output saying it's executing the workers.

:rails_env vs :app_env

Hi!

In lib/capistrano-resque/capistrano_integration.rb you sometimes use :rails_env and sometimes :app_env. What is the difference? And why not always just :rails_env? My Capistrano didn't have :app_env and i had to create it so i was wondering.

Thank You!
Kai

Resque does not start through capistrano-resque for my project

I've got a project which is using Rails 3.0.11 and I've added capistrano-resque to it. When I try and start it using 'cap resque:start' it says it's executing the following line:

cd /home/vps/aad/current && RAILS_ENV=production QUEUE=\"email_queue\"            PIDFILE=./tmp/pids/resque_work_1.pid BACKGROUND=yes VERBOSE=1            bundle exec rake environment resque:work

After it finishes this command I check the resque-web and processes on the server and there are no resque jobs running. However if I ssh into my server and copy that command above I can start a resque process fine.

I can also stop the process I started manually using the 'cap resque:stop' command. So it's half working.

Here are some of the versions of Gems I'm using:

resque (1.23.0)
capistrano (2.13.5)
capistrano-resque (0.0.9)

Here is the setup I have in my deploy.rb

# Resque
role :resque_worker, "<project url>"
role :resque_scheduler, "<project url>"

set :workers, { "email_queue" => 2 }

I have added the following to my Capfile

load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }

require "capistrano-resque"

load 'config/deploy' # remove this line to skip loading any of the default tasks

Expand README

The README doesn't make it clear that you can assign specific servers (via roles) to work on completely separate resque queues. For example

role :worker_server_A,  <server-ip-A>
role :worker_servers_B_and_C,  [<server-ip-B>, <server-ip-C>]

set :workers, {
  worker_server_A: {
    "queue-1" => 1,
    "queue-2" => 5
  },
  worker_servers_B_and_C: {
    "queue-3" => 1,
    "queue-4" => 9
  }
}

This is a great feature that I'm glad I found by looking through the source. Thanks!

help testing against edge resque

Hey there!

I'm gearing up to work on Resque 2.0, and I'd like to coordinate better with plugin authors to make sure stuff doesn't break.

I'd like to know a few things:

  1. Can I do something to help get you testing against edge Resque?
  2. Are you monkey-patching anything in Resque currently? Can 2.0 expose an API to help you not have to do that any more?
  3. Do you need any help in bringing your plugin up-to-date with the latest Resque?

Thanks!

Related: https://github.com/defunkt/resque/issues/880

Random failure of starting workers

I have 2 servers and each has 2 workers.

cap production resque:start

It starts 1 worker for each server sometimes, and sometimes 1 worker missing for one server. PID files exist but processes go away. It can be normal after trying a few times.

capistrano (2.14.2)
capistrano-resque (0.1.0)
resque (1.23.0)
rails (3.2.8)
rake (10.0.3)

How do you start a worker on all queues?

Hey,

The README is not clear about this. What should one do to run a worker who process tasks from all queues (i.e. QUEUE=* rake environment resque:work > /dev/null 2>&1 &)? It seems to be set :workers, { "*" => 1 }.

I also have a problem deploying with Rails not in the root the repository. start_command assumes rails is in the root directory. I hack fix is to change set :current_path, '/subdirectory/rails/path'

I also had to make sure the pids folder is there: mkdir -p tmp/pids

Cap V3 cannot load such file -- capistrano-resque

Just added capistrano-resque from master (2c73a2a)
Gemfile:

gem 'capistrano', '~> 3.0.1'
gem 'capistrano-rails', '~> 1.1.0'
gem 'capistrano-bundler', '~> 1.1.1'
gem 'capistrano-rvm', '~> 0.1.0'
gem "capistrano-resque", github: 'sshingler/capistrano-resque', require: false

Capfile:

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano-resque'

And now I get an error:

cap -vT
cap aborted!
cannot load such file -- capistrano-resque

Cap 3 version requires sudo to resque:stop (or restart)

I tried out this gem with Capistrano 3 and ran into the problem where it was requiring sudo in the resque:stop command. I do not want or need to use sudo to restart the resque processes.

lib/capistrano-resque/tasks/capistrano-resque.rake line 72 calls sudo and I didn't see a way to override it in Cap 3 without monkey-patching (which I ended up doing).

Question: If the resque process is started without sudo (using normal user permissions) why should it need sudo to stop it?! Can't we just remove that four letter word?

Running resque as a different user

I'm deploying with one user, but would like to run resque as the user the app runs with. It'd be great of capistrano-resque would allow to specify a user to run as. This could be either by setting the ssh user option, or using sudo with a specific user.

A simple solution would be to give the option of prepending the command - a capistrano-resque user could add a sudo :as => there.

Would this be a useful feature?

Capistrano not loading capistrano-resque tasks

Hi,

I'm currently using capistrano 2.12.0, and added require 'capistrano-resque' to my deploy file. Even so, the tasks of this gem don't get loaded. When I type capistrano -vT, I don't see the tasks of this gem.

I see resque:start_workers and resque:stop_workers listed by cap, but I think they're defined elsewhere (prob by cap itself?).

Thanks,
Tiago Franco

LOGFILE=./log/resque-worker#{i}.log appears to have no effect

I didn't see a log/resque-worker0.log file get created after starting my worker.

I also grep'd for LOGFILE in git://github.com/defunkt/resque.git and didn't see any references to it, so I don't think this option has any effect, and should be removed from the capistrano tasks...

I would really like to see the output from resque though. Is there any way to enable logging??

(Maybe if we don't use BACKGROUND=yes it would output to stdout?)

Not Working correctly with Resque 1.26

I have recently updated from resque 1.25 to 1.26 and things start to get wired, the workers would appear to be forked but not registered with the Resque.workers

In my case I was supposed to have 10 workers, after running resque:start I only got 5 workers

when entering ps aux | grep resque the 10 workers appear
but in the terminal using Resque.workers or resque-web only 5 appears that are accepting jobs

Error when cap deploy

Hello!

On Mac osx, rvm. Rails 3.2.12, ruby 1.9.3, i've always this error when i try to use cap task :

/Users/xxx/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/configuration/variables.rb:122:in `method_missing_with_variables': undefined method `_cset' for #<Capistrano::Configuration:0x007f995390ef40> (NoMethodError)
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-resque-0.1.0/lib/capistrano-resque/capistrano_integration.rb:9:in `block in load_into'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/configuration/loading.rb:97:in `instance_eval'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/configuration/loading.rb:97:in `load'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/configuration/loading.rb:83:in `load'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-resque-0.1.0/lib/capistrano-resque/capistrano_integration.rb:7:in `load_into'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-resque-0.1.0/lib/capistrano-resque/capistrano_integration.rb:126:in `<top (required)>'
    from /Users/yzack/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from /Users/yzack/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-resque-0.1.0/lib/capistrano-resque.rb:2:in `<top (required)>'
    from /Users/yzack/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
    from /Users/yzack/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
    from /Users/yzack/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/configuration/loading.rb:152:in `require'
    from Capfile:4:in `load'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/configuration/loading.rb:93:in `instance_eval'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/configuration/loading.rb:93:in `load'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/configuration/loading.rb:172:in `load_from_file'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/configuration/loading.rb:89:in `load'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/configuration/loading.rb:86:in `block in load'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/configuration/loading.rb:86:in `each'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/configuration/loading.rb:86:in `load'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/cli/execute.rb:65:in `block in load_recipes'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/cli/execute.rb:65:in `each'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/cli/execute.rb:65:in `load_recipes'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/cli/execute.rb:31:in `execute!'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/lib/capistrano/cli/execute.rb:14:in `execute'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/gems/capistrano-2.14.2/bin/cap:4:in `<top (required)>'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/bin/cap:19:in `load'
    from /Users/yzack/.rvm/gems/ruby-1.9.3-p194@fnordmetric/bin/cap:19:in `<main>'

Everything working well without capistrano-resque gem
See it ?

cap -vT shows no resque tasks

Rails 3.2, Ruby 1.9.3p392
Gemfile:

group :capistrano do
  gem 'capistrano'
  gem 'capistrano-resque', '~> 0.1.0'
  ...
end

Capfile: require 'capistrano-resque'

config/deploy.rb:

set :workers, { "*" => 5 }
role :resque_worker,    "box.address"
role :resque_scheduler, "box.address"

I can provide more detail if needed

capistrano-resque incompatible with capistrano 3.0.0: uninitialized constant Capistrano::Configuration (NameError)

Hello,

There is an issue with the capistrano dependency in the gemspec.

I get this error with capistrano version 3.0.0

/Users/etagwerker/.rvm/gems/ruby-1.9.3-p327@ombu/bundler/gems/capistrano-resque-0ec1d45e72c5/lib/capistrano-resque/capistrano_integration.rb:124:in `<top (required)>': uninitialized constant Capistrano::Configuration (NameError)
    from /Users/etagwerker/.rvm/gems/ruby-1.9.3-p327@ombu/gems/backports-3.3.5/lib/backports/tools.rb:328:in `require'
    from /Users/etagwerker/.rvm/gems/ruby-1.9.3-p327@ombu/gems/backports-3.3.5/lib/backports/tools.rb:328:in `require_with_backports'
    from /Users/etagwerker/.rvm/gems/ruby-1.9.3-p327@ombu/bundler/gems/capistrano-resque-0ec1d45e72c5/lib/capistrano-resque.rb:2:in `<top (required)>'
    from /Users/etagwerker/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.2/lib/bundler/runtime.rb:68:in `require'
    from /Users/etagwerker/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.2/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/etagwerker/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.2/lib/bundler/runtime.rb:66:in `each'
    from /Users/etagwerker/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.2/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/etagwerker/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.2/lib/bundler/runtime.rb:55:in `each'
    from /Users/etagwerker/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.2/lib/bundler/runtime.rb:55:in `require'
    from /Users/etagwerker/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.2/lib/bundler.rb:128:in `require'
    from /Users/etagwerker/Projects/ombu_store/config/application.rb:9:in `<top (required)>'

I suggest a tweak to the project's gemspec and a new release (maybe 0.2.0?)

I'll send a pull request which should avoid this issue.

Let me know what you think.

Thanks

The resque:stop command should not fail if no pid files are found

This is the failure I get when I have this hook:

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

and I run deploy:restart for the first time:

  * 20:41:34 == Currently executing `resque:stop'
  * executing "ls /app/current/tmp/pids/resque_work*.pid"
    [hostname] executing command
    command finished in 969ms
ls: cannot access /app/current/tmp/pids/resque_work*.pid: No such file or directory
failed: ... -c 'ls /app/current/tmp/pids/resque_work*.pid'

Changing current_pids to this appears to fix the problem:

def current_pids
  capture("ls #{current_path}/tmp/pids/resque_work*.pid 2>/dev/null || true").strip.split(/\r{0,1}\n/)
end

Gem requires rake task

I don't see any rake tasks provided by resque gem. So cap resque doesn't work at all.

Having issues deploying

So when I deploy, the resque workers code base are not being updated correctly.

I have a worker that I deployed up and running on Nov 13th. Then I created a new one 5 days ago. Both are registered in my /resque page.

I also updated worker_1 and redeployed it.

Now. here are the workers that are listed.

host_worker.rb : version Nov 13th (even though I edited and redeployed Nov 27th)
service_worker.rb version Nov 27th

Im using Cap3 and ca-resq. and various other things.

incompatibility between capistrano-resque and capistrano-rbenv

I'm using capistrano 3.2.1 with capistrano-resque gem to restart rasque workers on deployment. Always getting this error.

cd /home/azureuser/apps/app_production/current && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.1 /usr/bin/env nohup RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.1 ~/.rbenv/bin/rbenv exec bundle exec rake RACK_ENV=production RAILS_ENV=production QUEUE="mailer" PIDFILE=/home/azureuser/apps/app_production/shared/tmp/pids/resque_work_1.pid BACKGROUND=yes VERBOSE=1 INTERVAL=5 environment resque:work >> log/resque.log 2>> log/resque.log )
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: nohup exit status: 127
nohup stdout: Nothing written
nohup stderr: Nothing written
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:16:in `rescue in block (2 levels) in execute'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
SSHKit::Command::Failed: nohup exit status: 127

If I check my error log at apps/app_production/current/log/resque.log it shows.

ohup: failed to run command `RBENV_ROOT=/home/azureuser/.rbenv': No such file or directory

I brought the issue to stackoverflow and here is the thread.

http://stackoverflow.com/questions/29705693/rails-deployment-with-capistrano-and-start-resque-workers

The documentation doesn't match the release

The version of the gem installed from rubygems still provides the following tasks:

resque:start_workers
resque:stop_workers

It looks like a version bump and a rake release will do the trick.

New gem release?

I'm having to pull from github in my gemfile in order to get e0f99f6. If it's not too much trouble, I'd feel a lot better about pulling from the office Rubygems source. Thanks for putting this gem together. It is great.

failed to create symbolic link

Hello, I have a Capistrano set up with the below configuration in my Capfile. When doing a cap staging deploy things normally work fine. However, upon implementing Capistrano-Resque, I receive an error: "failed to create symbolic link".

Here is my Capfile:

# Load DSL and set up stages
require 'capistrano/setup'

# Include default deployment tasks
require 'capistrano/deploy'


require 'capistrano/rbenv'
require 'capistrano/bundler'
require 'capistrano/rails/console'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

require 'capistrano/unicorn_nginx'
require 'capistrano/postgresql'
require 'capistrano-db-tasks'

require 'capistrano-resque'
require 'capistrano/clockwork'

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

(I'm using Capistrano 3.6.1, and Capistrano-Resque 0.2.2 with require: false, as prescribed)

The backtrace of the error is as follows. Does anyone know what's going on here?

00:11 deploy:symlink:linked_files
      01 mkdir -p /home/deploy/apps/myapp_staging/releases/20160909140832/config
    ✔ 01 [email protected] 0.237s
    ✔ 01 [email protected] 0.238s
      02 ln -s /home/deploy/apps/myapp_staging/shared/config/secrets.yml /home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml
    ✔ 02 [email protected] 0.296s
      02 ln: failed to create symbolic link ‘/home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml’
      02 : File exists
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: ln exit status: 1
ln stdout: Nothing written
ln stderr: ln: failed to create symbolic link ‘/home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml’: File exists

SSHKit::Command::Failed: ln exit status: 1
ln stdout: Nothing written
ln stderr: ln: failed to create symbolic link ‘/home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml’: File exists

Tasks: TOP => deploy:symlink:linked_files
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as [email protected]: ln exit status: 1
ln stdout: Nothing written
ln stderr: ln: failed to create symbolic link ‘/home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml’: File exists

** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:

  INFO [b89a83c7] Finished in 0.238 seconds with exit status 0 (successful).
 DEBUG [ab33b1bd] Running [ -L /home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml ] as [email protected]
 DEBUG [ab33b1bd] Command: [ -L /home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml ]
 DEBUG [7d27abbf] Finished in 0.267 seconds with exit status 1 (failed).
 DEBUG [8da38f89] Running [ -f /home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml ] as [email protected]
 DEBUG [8da38f89] Command: [ -f /home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml ]
 DEBUG [ab33b1bd] Finished in 0.267 seconds with exit status 1 (failed).
 DEBUG [2a2c0ce7] Running [ -f /home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml ] as [email protected]
 DEBUG [2a2c0ce7] Command: [ -f /home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml ]
 DEBUG [8da38f89] Finished in 0.245 seconds with exit status 1 (failed).
  INFO [7a175e21] Running /usr/bin/env ln -s /home/deploy/apps/myapp_staging/shared/config/secrets.yml /home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml as deploy…
 DEBUG [7a175e21] Command: ( export RBENV_ROOT="/home/deploy/.rbenv" RBENV_VERSION="2.2.4" ; /usr/bin/env ln -s /home/deploy/apps/myapp_staging/shared/config/secrets.yml /home/deploy/apps/…
 DEBUG [2a2c0ce7] Finished in 0.245 seconds with exit status 1 (failed).
  INFO [00c3b638] Running /usr/bin/env ln -s /home/deploy/apps/myapp_staging/shared/config/secrets.yml /home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml as deploy…
 DEBUG [00c3b638] Command: ( export RBENV_ROOT="/home/deploy/.rbenv" RBENV_VERSION="2.2.4" ; /usr/bin/env ln -s /home/deploy/apps/myapp_staging/shared/config/secrets.yml /home/deploy/apps/…
  INFO [00c3b638] Finished in 0.296 seconds with exit status 0 (successful).
 DEBUG [3410bee8] Running [ -L /home/deploy/apps/myapp_staging/releases/20160909140832/config/sunspot.yml ] as [email protected]
 DEBUG [3410bee8] Command: [ -L /home/deploy/apps/myapp_staging/releases/20160909140832/config/sunspot.yml ]
 DEBUG [7a175e21]       ln: failed to create symbolic link ‘/home/deploy/apps/myapp_staging/releases/20160909140832/config/secrets.yml’
 DEBUG [7a175e21]       : File exists

Unable to start resque, there is no log file created.

I am also unable to start resque workers in my code. I do not get any error messages but there is no resque worker running in background. I have also posted this question on stack overflow.

Versions used

capistrano-resque  => 0.2.2
resque => 1.25.2
ruby=> 2.1.0

There is no log file created for resque. I even tried creating a log file and then trying to start resque but it didn't work.

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"

deploy.rb

lock '3.6.1'

set :application, 'test_app'
set :repo_url, 'sample.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')

logs

In logs its clear that resque:restart is called but it does not start a worker.

** 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

Stale PIDs cause resque:stop and resque:restart to fail

How does one prevent resque:stop and and resque:restart from failing a deployment with stale PIDs? It seems that a rm -f resque_work*.pid or similar would easily remedy this.

  • 2013-04-11 15:20:39 executing `resque:stop'
  • executing "if [ -e /var/www/app/current/tmp/pids/resque_work_1.pid ]; then for f in ls /var/www/app/current/tmp/pids/resque_work*.pid; do sudo -p 'sudo password: ' kill -s QUIT cat $f && rm $f ;done ;fi"
    servers: ["worker1.server.com"]
    [worker1.server.com] executing command
    ** [out :: worker1.server.com] kill: No such process
    ** [out :: worker1.server.com] kill: No such process
    command finished in 328ms
    failed: "sh -c 'if [ -e /var/www/app/current/tmp/pids/resque_work_1.pid ]; then for f in ls /var/www/app/current/tmp/pids/resque_work*.pid; do sudo -p '''sudo password: ''' kill -s QUIT cat $f && rm $f ;done ;fi'" on worker1.server.com

Workers' processes don't die

Hello
I'm using your gem, last version
I have following strings in deploy.rb:

...

set :workers, { "account_logs_queue" => 1, 'xmpp_worker' => 8, 'mails_queue' => 1, 'operator_logs_queue' => 1, 'send_reports_queue' => 10, "update_dictionaries_queue" => 1, 'closing_tickets_queue' => 1 }
...

Resque workers start normally and as I need, but after I run cap resque:stop processes are still alive. Workers are not shown in resque-web.
On next cap resque:start new processes created.
What can be the problem?

cap production resque:restart failing, with nothing written to stdout

[e6956e94] Command: cd /var/www/html/server/current && bundle exec rake RAILS_ENV=production QUEUE="credential" PIDFILE=/var/www/html/server/shared/tmp/pids/resque_work_1.pid BACKGROUND=yes VERBOSE=1 INTERVAL=5  resque:work >> /dev/null 2>> /dev/null
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as user@server: rake exit status: 1
rake stdout: Nothing written
rake stderr: Nothing written

SSHKit::Command::Failed: rake exit status: 1
rake stdout: Nothing written
rake stderr: Nothing written

Tasks: TOP => resque:start
(See full trace by running task with --trace)

In deploy/production.rb:

role :resque_worker, 'server'
role :resque_scheduler, 'server'
set :workers, {:queue => 2}

undefined method `instance' for Capistrano::Configuration:Class

Getting undefined methodinstance' for Capistrano::Configuration:Classwhen I runcap production deploy` with capistrano v3.

I've put require 'capistrano-resque' in my Capfile.
I have this in my deploy rb:

role :resque_worker, "10.97.106.134"
role :resque_scheduler, "10.97.106.134"

set :workers, { "attendee_importer" => 2 }

any tips?

Lost workers

I use this gem to deploy workers.

But I start 10 workers, only 9, 8 is started.

Please help me!

resque:start hangs

capistrano-resque is hanging every time I issue a resque:start or resque:restart.

 INFO [f0004d2a] Running ~/.rvm/bin/rvm 2.1.0@content do bundle exec rake RAILS_ENV=staging QUEUE="*" PIDFILE=./tmp/pids/resque_work_1.pid BACKGROUND=yes VERBOSE=1 INTERVAL=5 environment resque:work on cgapp02
DEBUG [f0004d2a] Command: cd /var/www/vhosts/staging.contentapp.com/current && ~/.rvm/bin/rvm 2.1.0@content do bundle exec rake RAILS_ENV=staging QUEUE="*" PIDFILE=./tmp/pids/resque_work_1.pid BACKGROUND=yes VERBOSE=1 INTERVAL=5 environment resque:work
DEBUG [5c66b7aa]    rspec rake task not loaded
DEBUG [f0004d2a]    rspec rake task not loaded
 INFO [5c66b7aa] Finished in 6.517 seconds with exit status 0 (successful).
 INFO [f0004d2a] Finished in 6.387 seconds with exit status 0 (successful).
# Hangs here until I Ctrl-C

I thought it might be related to the SSHKit problem referenced in #74, but I upgraded SshKit to use gem "sshkit", github: capistrano/sshkit which didn't help. Also tried added the SSHKit::Backend::Netssh.pool.idle_timeout = 0 statement, which was also unsuccessful.

Any suggestions on where I can start looking?

different workers set for each server

Hello,

It would be helpful to be able to configure specific sets of workers for specific servers. For example:

role :slow_worker, 'A'
role :fast_worker, 'X'
set :workers, { :slow_worker => { 'easy_task' => 1, 'other_easy_task' => 2 }, :fast_worker => { 'heavy_lifting' => 1, ... } }

For example, in our setup, we have some large servers on which we would like to run resource intensive image processing tasks, and some lighter servers on which we would run easier tasks.

I believe the helper methods (remote_file_exists?, remote_process_exists? and current_pids) should expect a new, optional parameter 'role' and only the start task must be changed to send the role parameter.

Do you believe this would be a useful addition to capistrano-resque ?

resque:* produces no output

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.

Resque scheduler wont run in background

Hi,
I try to use "resque:scheduler:start" task but I found out that resque scheduler wont run in background:

*** [Resque Scheduler] Resque scheduler not running
  * executing `resque:scheduler:start'
  * executing "cd /home/homecard/app/production/current && RAILS_ENV=production PIDFILE=./tmp/pids/scheduler.pid BACKGROUND=yes bundle exec rake resque:scheduler"
    servers: ["homecard.com.pl"]
    [homecard.com.pl] executing command
 ** [out :: homecard.com.pl] 2012-09-03 00:45:07 Scheduling generate_invoices
... keps hanging

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.