capistrano-resque 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'resque', '~> 1.21.0'
3
+ gem 'resque', :git => 'git://github.com/defunkt/resque.git', :branch => '1-x-stable'
4
+ gem 'resque-scheduler'
4
5
 
5
6
  gemspec
@@ -1,43 +1,58 @@
1
+ GIT
2
+ remote: git://github.com/defunkt/resque.git
3
+ revision: 3cb5c07dde21500afe17232ec43e6317cc96e6d1
4
+ branch: 1-x-stable
5
+ specs:
6
+ resque (1.23.0)
7
+ multi_json (~> 1.0)
8
+ redis-namespace (~> 1.0)
9
+ sinatra (>= 0.9.2)
10
+ vegas (~> 0.1.2)
11
+
1
12
  PATH
2
13
  remote: .
3
14
  specs:
4
- capistrano-resque (0.0.6)
15
+ capistrano-resque (0.0.8)
5
16
  capistrano
17
+ resque
18
+ resque-scheduler
6
19
 
7
20
  GEM
8
21
  remote: http://rubygems.org/
9
22
  specs:
10
- capistrano (2.12.0)
23
+ capistrano (2.13.5)
11
24
  highline
12
25
  net-scp (>= 1.0.0)
13
26
  net-sftp (>= 2.0.0)
14
27
  net-ssh (>= 2.0.14)
15
28
  net-ssh-gateway (>= 1.1.0)
16
- highline (1.6.13)
29
+ highline (1.6.15)
17
30
  multi_json (1.3.6)
18
31
  net-scp (1.0.4)
19
32
  net-ssh (>= 1.99.1)
20
33
  net-sftp (2.0.5)
21
34
  net-ssh (>= 2.0.9)
22
- net-ssh (2.5.2)
35
+ net-ssh (2.6.1)
23
36
  net-ssh-gateway (1.1.0)
24
37
  net-ssh (>= 1.99.1)
25
38
  rack (1.4.1)
26
39
  rack-protection (1.2.0)
27
40
  rack
28
- redis (3.0.1)
29
- redis-namespace (1.2.0)
41
+ redis (3.0.2)
42
+ redis-namespace (1.2.1)
30
43
  redis (~> 3.0.0)
31
- resque (1.21.0)
32
- multi_json (~> 1.0)
33
- redis-namespace (~> 1.0)
34
- sinatra (>= 0.9.2)
35
- vegas (~> 0.1.2)
36
- sinatra (1.3.2)
44
+ resque-scheduler (2.0.0)
45
+ redis (>= 2.0.1)
46
+ resque (>= 1.20.0)
47
+ rufus-scheduler
48
+ rufus-scheduler (2.0.17)
49
+ tzinfo (>= 0.3.23)
50
+ sinatra (1.3.3)
37
51
  rack (~> 1.3, >= 1.3.6)
38
52
  rack-protection (~> 1.2)
39
53
  tilt (~> 1.3, >= 1.3.3)
40
54
  tilt (1.3.3)
55
+ tzinfo (0.3.34)
41
56
  vegas (0.1.11)
42
57
  rack (>= 1.0.0)
43
58
 
@@ -46,4 +61,5 @@ PLATFORMS
46
61
 
47
62
  DEPENDENCIES
48
63
  capistrano-resque!
49
- resque (~> 1.21.0)
64
+ resque!
65
+ resque-scheduler
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ # Changes
2
+
3
+ Using SIGQUIT to kill processes as they aren't terminating properly.
4
+
1
5
  # Capistrano Resque
2
6
 
3
7
  Basic tasks for putting some Resque in your Cap.
@@ -11,6 +15,9 @@ require "capistrano-resque"
11
15
  ### In your deploy.rb:
12
16
 
13
17
  ```
18
+ role :resque_worker, "app_domain"
19
+ role :resque_scheduler, "app_domain"
20
+
14
21
  set :workers, { "my_queue_name" => 2 }
15
22
  ```
16
23
 
@@ -33,6 +40,7 @@ Running cap -vT | grep resque should give you...
33
40
 
34
41
  ```
35
42
  ➔ cap -vT | grep resque
43
+ cap resque:status # Check worksers status
36
44
  cap resque:start # Start Resque workers
37
45
  cap resque:stop # Quit running Resque workers
38
46
  cap resque:restart # Restart running Resque workers
@@ -51,9 +59,23 @@ after "deploy:restart", "resque:restart"
51
59
  ```
52
60
  ### Logging
53
61
 
54
- I've decided to lose the logging ability altogether, in order to keep up with recent versions of Resque, following the chatter on: https://github.com/defunkt/resque/pull/450
62
+ 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.
63
+
64
+ In your Gemfile, you will need to specify:
65
+
66
+ ```
67
+ gem 'resque', :git => 'git://github.com/defunkt/resque.git', :branch => '1-x-stable'
68
+ ```
69
+
70
+ Also, you will need to include:
71
+
72
+ ```
73
+ Resque.logger = Logger.new("new_resque_log_file")
74
+ ```
75
+
76
+ ...somewhere sensible, such as in your resque.rake, to achieve logging.
55
77
 
56
- If logging is important to you, there's still the 0.0.4 release of this project.
78
+ 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.
57
79
 
58
80
  ### License
59
81
 
@@ -16,4 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.require_paths = ["lib"]
17
17
 
18
18
  gem.add_runtime_dependency "capistrano"
19
+ gem.add_runtime_dependency "resque"
20
+ gem.add_runtime_dependency "resque-scheduler"
19
21
  end
@@ -7,6 +7,7 @@ module CapistranoResque
7
7
  capistrano_config.load do
8
8
 
9
9
  _cset(:workers, {"*" => 1})
10
+ _cset(:resque_kill_signal, "QUIT")
10
11
 
11
12
  def workers_roles
12
13
  return workers.keys if workers.first[1].is_a? Hash
@@ -23,13 +24,43 @@ module CapistranoResque
23
24
  end
24
25
  end
25
26
 
27
+ def status_command
28
+ "if [ -e #{current_path}/tmp/pids/resque_work_1.pid ]; then \
29
+ for f in $(ls #{current_path}/tmp/pids/resque_work*.pid); \
30
+ do ps -p $(cat $f) | sed -n 2p ; done \
31
+ ;fi"
32
+ end
33
+
34
+ def start_command(queue, pid)
35
+ "cd #{current_path} && RAILS_ENV=#{rails_env} QUEUE=\"#{queue}\" \
36
+ PIDFILE=#{pid} BACKGROUND=yes VERBOSE=1 \
37
+ #{fetch(:bundle_cmd, "bundle")} exec rake environment resque:work"
38
+ end
39
+
40
+ def stop_command
41
+ "if [ -e #{current_path}/tmp/pids/resque_work_1.pid ]; then \
42
+ for f in `ls #{current_path}/tmp/pids/resque_work*.pid`; \
43
+ do #{try_sudo} kill -s #{resque_kill_signal} `cat $f` \
44
+ && rm $f ;done \
45
+ ;fi"
46
+ end
47
+
48
+ def start_scheduler(pid)
49
+ "cd #{current_path} && RAILS_ENV=#{rails_env} \
50
+ PIDFILE=#{pid} BACKGROUND=yes \
51
+ #{fetch(:bundle_cmd, "bundle")} exec rake resque:scheduler"
52
+ end
53
+
54
+ def stop_scheduler(pid)
55
+ "if [ -e #{pid} ]; then \
56
+ #{try_sudo} kill $(cat #{pid}) ; rm #{pid} \
57
+ ;fi"
58
+ end
59
+
26
60
  namespace :resque do
27
61
  desc "See current worker status"
28
62
  task :status, :roles => lambda { workers_roles() }, :on_no_matching_servers => :continue do
29
- command = "if [ -e #{current_path}/tmp/pids/resque_work_1.pid ]; then \
30
- for f in $(ls #{current_path}/tmp/pids/resque_work*.pid); do ps -p $(cat $f) | sed -n 2p ;done \
31
- ;fi"
32
- run(command)
63
+ run(status_command)
33
64
  end
34
65
 
35
66
  desc "Start Resque workers"
@@ -40,21 +71,22 @@ module CapistranoResque
40
71
  puts "Starting #{number_of_workers} worker(s) with QUEUE: #{queue}"
41
72
  number_of_workers.times do
42
73
  pid = "./tmp/pids/resque_work_#{worker_id}.pid"
43
- run("cd #{current_path} && RAILS_ENV=#{rails_env} QUEUE=\"#{queue}\" \
44
- PIDFILE=#{pid} BACKGROUND=yes VERBOSE=1 #{fetch(:bundle_cmd, "bundle")} exec rake environment resque:work >> #{shared_path}/log/resque.log 2>&1 &",
45
- :roles => role)
74
+ run(start_command(queue, pid), :roles => role)
46
75
  worker_id += 1
47
76
  end
48
77
  end
49
78
  end
50
79
  end
51
80
 
81
+ # See https://github.com/defunkt/resque#signals for a descriptions of signals
82
+ # QUIT - Wait for child to finish processing then exit (graceful)
83
+ # TERM / INT - Immediately kill child then exit (stale or stuck)
84
+ # USR1 - Immediately kill child but don't exit (stale or stuck)
85
+ # USR2 - Don't start to process any new jobs (pause)
86
+ # CONT - Start to process new jobs again after a USR2 (resume)
52
87
  desc "Quit running Resque workers"
53
88
  task :stop, :roles => lambda { workers_roles() }, :on_no_matching_servers => :continue do
54
- command = "if [ -e #{current_path}/tmp/pids/resque_work_1.pid ]; then \
55
- for f in `ls #{current_path}/tmp/pids/resque_work*.pid`; do #{try_sudo} kill `cat $f` ; rm $f ;done \
56
- ;fi"
57
- run(command)
89
+ run(stop_command)
58
90
  end
59
91
 
60
92
  desc "Restart running Resque workers"
@@ -66,18 +98,14 @@ module CapistranoResque
66
98
  namespace :scheduler do
67
99
  desc "Starts resque scheduler with default configs"
68
100
  task :start, :roles => :resque_scheduler do
69
- run "cd #{current_path} && RAILS_ENV=#{rails_env} \
70
- PIDFILE=./tmp/pids/scheduler.pid BACKGROUND=yes bundle exec rake resque:scheduler >> #{shared_path}/log/resque_scheduler.log 2>&1 &"
101
+ pid = "#{current_path}/tmp/pids/scheduler.pid"
102
+ run(start_scheduler(pid))
71
103
  end
72
104
 
73
105
  desc "Stops resque scheduler"
74
106
  task :stop, :roles => :resque_scheduler do
75
107
  pid = "#{current_path}/tmp/pids/scheduler.pid"
76
- command = "if [ -e #{pid} ]; then \
77
- #{try_sudo} kill $(cat #{pid}) ; rm #{pid} \
78
- ;fi"
79
- run(command)
80
-
108
+ run(stop_scheduler(pid))
81
109
  end
82
110
 
83
111
  task :restart do
@@ -1,5 +1,5 @@
1
1
  module CapistranoResque
2
2
  unless defined?(::CapistranoResque::VERSION)
3
- VERSION = "0.0.7".freeze
3
+ VERSION = "0.0.8".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-resque
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-15 00:00:00.000000000 Z
12
+ date: 2012-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
16
- requirement: &70296963636080 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,44 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70296963636080
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: resque
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: resque-scheduler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
25
62
  description: Capistrano plugin that integrates Resque server tasks.
26
63
  email: shingler@gmail.com
27
64
  executables: []
@@ -58,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
95
  version: '0'
59
96
  requirements: []
60
97
  rubyforge_project:
61
- rubygems_version: 1.8.15
98
+ rubygems_version: 1.8.24
62
99
  signing_key:
63
100
  specification_version: 3
64
101
  summary: Resque integration for Capistrano