capistrano-resque 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- capistrano-resque (0.0.3)
15
+ capistrano-resque (0.0.4)
16
16
  capistrano
17
17
 
18
18
  GEM
@@ -24,13 +24,13 @@ GEM
24
24
  net-sftp (>= 2.0.0)
25
25
  net-ssh (>= 2.0.14)
26
26
  net-ssh-gateway (>= 1.1.0)
27
- highline (1.6.11)
27
+ highline (1.6.13)
28
28
  multi_json (1.3.4)
29
29
  net-scp (1.0.4)
30
30
  net-ssh (>= 1.99.1)
31
31
  net-sftp (2.0.5)
32
32
  net-ssh (>= 2.0.9)
33
- net-ssh (2.3.0)
33
+ net-ssh (2.5.2)
34
34
  net-ssh-gateway (1.1.0)
35
35
  net-ssh (>= 1.99.1)
36
36
  rack (1.4.1)
data/README.md CHANGED
@@ -11,11 +11,25 @@ require "capistrano-resque"
11
11
  ### In your deploy.rb:
12
12
 
13
13
  ```
14
- set :queue_name, "my_queue_name"
15
- set :num_of_queues, 2
14
+ set :workers, { "my_queue_name" => 2 }
16
15
  ```
17
16
 
18
- Then, running cap -vT | grep resque should give you...
17
+ You can also specify multiple queues and the number of workers
18
+ for each queue:
19
+
20
+ ```
21
+ set :workers, { "archive" => 1, "mailing" => 3, "search_index, cache_warming" => 1 }
22
+ ```
23
+
24
+ The above will start five workers in total:
25
+
26
+ * one listening on the `archive` queue
27
+ * one listening on the `search_index, cache_warming` queue
28
+ * three listening on the `mailing` queue
29
+
30
+ ### The tasks
31
+
32
+ Running cap -vT | grep resque should give you...
19
33
 
20
34
  ```
21
35
  ➔ cap -vT | grep resque
@@ -24,7 +38,7 @@ cap resque:stop # Quit running Resque workers
24
38
  cap resque:restart # Restart running Resque workers
25
39
  ```
26
40
 
27
- ### Restart on deployer
41
+ ### Restart on deployment
28
42
 
29
43
  To restart you workers automatically when `cap deploy:restart` is executed
30
44
  add the following line to your `deploy.rb`:
@@ -33,3 +47,6 @@ add the following line to your `deploy.rb`:
33
47
  after "deploy:restart", "resque:restart"
34
48
  ```
35
49
 
50
+ ## Logging
51
+
52
+ Currently, resque doesn't log to a logfile. I'm using the 'logfile' branch of http://github.com/sj26/resque in my consuming Gemfile to achieve this functionality. Hopefully that will get merged into defunkt/resque soon.
@@ -6,8 +6,7 @@ module CapistranoResque
6
6
  def self.load_into(capistrano_config)
7
7
  capistrano_config.load do
8
8
 
9
- _cset(:num_of_queues, 1)
10
- _cset(:queue_name, "*")
9
+ _cset(:workers, {"*" => 1})
11
10
  _cset(:app_env, (fetch(:rails_env) rescue "production"))
12
11
  _cset(:verbosity, 1)
13
12
 
@@ -20,7 +19,7 @@ module CapistranoResque
20
19
  end
21
20
 
22
21
  def current_pids
23
- capture("ls #{current_path}/tmp/pids/resque_work*.pid").strip.split(/\r{0,1}\n/)
22
+ capture("ls #{current_path}/tmp/pids/resque_work*.pid 2>/dev/null || true").strip.split(/\r{0,1}\n/)
24
23
  end
25
24
 
26
25
  namespace :resque do
@@ -39,12 +38,16 @@ module CapistranoResque
39
38
 
40
39
  desc "Start Resque workers"
41
40
  task :start do
42
- puts "Starting #{num_of_queues} worker(s) with QUEUE: #{queue_name}"
43
- num_of_queues.times do |i|
44
- pid = "./tmp/pids/resque_worker_#{i}.pid"
45
- run "cd #{current_path} && RAILS_ENV=#{app_env} QUEUE=#{queue_name} \
46
- PIDFILE=#{pid} BACKGROUND=yes LOGFILE=./log/resque-worker#{i}.log VVERBOSE=#{verbosity} \
47
- bundle exec rake environment resque:work"
41
+ worker_id = 1
42
+ workers.each_pair do |queue, number_of_workers|
43
+ puts "Starting #{number_of_workers} worker(s) with QUEUE: #{queue}"
44
+ number_of_workers.times do
45
+ pid = "./tmp/pids/resque_worker_#{worker_id}.pid"
46
+ run "cd #{current_path} && RAILS_ENV=#{app_env} QUEUE=\"#{queue}\" \
47
+ PIDFILE=#{pid} BACKGROUND=yes LOGFILE=./log/resque-worker#{worker_id}.log VVERBOSE=#{verbosity} \
48
+ bundle exec rake environment resque:work"
49
+ worker_id += 1
50
+ end
48
51
  end
49
52
  end
50
53
 
@@ -1,5 +1,5 @@
1
1
  module CapistranoResque
2
2
  unless defined?(::CapistranoResque::VERSION)
3
- VERSION = "0.0.3".freeze
3
+ VERSION = "0.0.4".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-resque
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Steven Shingler
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-06-12 00:00:00 Z
18
+ date: 2012-06-24 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: capistrano