capistrano-resque 0.0.6 → 0.0.7
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/LICENSE +20 -0
- data/README.md +5 -1
- data/lib/capistrano-resque/capistrano_integration.rb +41 -51
- data/lib/capistrano-resque/version.rb +1 -1
- metadata +27 -48
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Steven Shingler
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -53,4 +53,8 @@ after "deploy:restart", "resque:restart"
|
|
53
53
|
|
54
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
|
55
55
|
|
56
|
-
If logging is important to you, there's still the 0.0.4 release of this project.
|
56
|
+
If logging is important to you, there's still the 0.0.4 release of this project.
|
57
|
+
|
58
|
+
### License
|
59
|
+
|
60
|
+
Please see the included LICENSE file.
|
@@ -7,87 +7,77 @@ module CapistranoResque
|
|
7
7
|
capistrano_config.load do
|
8
8
|
|
9
9
|
_cset(:workers, {"*" => 1})
|
10
|
-
_cset(:app_env, (fetch(:rails_env) rescue "production"))
|
11
10
|
|
12
|
-
def
|
13
|
-
|
11
|
+
def workers_roles
|
12
|
+
return workers.keys if workers.first[1].is_a? Hash
|
13
|
+
[:resque_worker]
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
def for_each_workers(&block)
|
17
|
+
if workers.first[1].is_a? Hash
|
18
|
+
workers_roles.each do |role|
|
19
|
+
yield(role.to_sym, workers[role.to_sym])
|
20
|
+
end
|
21
|
+
else
|
22
|
+
yield(:resque_worker,workers)
|
23
|
+
end
|
22
24
|
end
|
23
25
|
|
24
26
|
namespace :resque do
|
25
27
|
desc "See current worker status"
|
26
|
-
task :status, :roles => :
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
else
|
32
|
-
logger.important("Down", "Resque Worker: #{pid}")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
28
|
+
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)
|
36
33
|
end
|
37
34
|
|
38
35
|
desc "Start Resque workers"
|
39
|
-
task :start, :roles => :
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
36
|
+
task :start, :roles => lambda { workers_roles() }, :on_no_matching_servers => :continue do
|
37
|
+
for_each_workers do |role, workers|
|
38
|
+
worker_id = 1
|
39
|
+
workers.each_pair do |queue, number_of_workers|
|
40
|
+
puts "Starting #{number_of_workers} worker(s) with QUEUE: #{queue}"
|
41
|
+
number_of_workers.times do
|
42
|
+
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)
|
46
|
+
worker_id += 1
|
47
|
+
end
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
desc "Quit running Resque workers"
|
53
|
-
task :stop, :roles => :
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
run "#{try_sudo} kill `cat #{pid}`"
|
59
|
-
else
|
60
|
-
run "rm #{pid}"
|
61
|
-
logger.important("Resque Worker #{pid} is not running.", "Resque")
|
62
|
-
end
|
63
|
-
else
|
64
|
-
logger.important("No PIDs found. Check if Resque is running.", "Resque")
|
65
|
-
end
|
66
|
-
end
|
53
|
+
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)
|
67
58
|
end
|
68
59
|
|
69
60
|
desc "Restart running Resque workers"
|
70
|
-
task :restart, :roles => :
|
61
|
+
task :restart, :roles => lambda { workers_roles() }, :on_no_matching_servers => :continue do
|
71
62
|
stop
|
72
63
|
start
|
73
64
|
end
|
74
|
-
|
65
|
+
|
75
66
|
namespace :scheduler do
|
76
67
|
desc "Starts resque scheduler with default configs"
|
77
68
|
task :start, :roles => :resque_scheduler do
|
78
69
|
run "cd #{current_path} && RAILS_ENV=#{rails_env} \
|
79
|
-
PIDFILE=./tmp/pids/scheduler.pid BACKGROUND=yes bundle exec rake resque:scheduler"
|
70
|
+
PIDFILE=./tmp/pids/scheduler.pid BACKGROUND=yes bundle exec rake resque:scheduler >> #{shared_path}/log/resque_scheduler.log 2>&1 &"
|
80
71
|
end
|
81
72
|
|
82
73
|
desc "Stops resque scheduler"
|
83
74
|
task :stop, :roles => :resque_scheduler do
|
84
75
|
pid = "#{current_path}/tmp/pids/scheduler.pid"
|
85
|
-
if
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
76
|
+
command = "if [ -e #{pid} ]; then \
|
77
|
+
#{try_sudo} kill $(cat #{pid}) ; rm #{pid} \
|
78
|
+
;fi"
|
79
|
+
run(command)
|
80
|
+
|
91
81
|
end
|
92
82
|
|
93
83
|
task :restart do
|
metadata
CHANGED
@@ -1,48 +1,37 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-resque
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 6
|
10
|
-
version: 0.0.6
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Steven Shingler
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-09-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: capistrano
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70296963636080 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :runtime
|
33
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70296963636080
|
34
25
|
description: Capistrano plugin that integrates Resque server tasks.
|
35
26
|
email: shingler@gmail.com
|
36
27
|
executables: []
|
37
|
-
|
38
28
|
extensions: []
|
39
|
-
|
40
29
|
extra_rdoc_files: []
|
41
|
-
|
42
|
-
files:
|
30
|
+
files:
|
43
31
|
- .gitignore
|
44
32
|
- Gemfile
|
45
33
|
- Gemfile.lock
|
34
|
+
- LICENSE
|
46
35
|
- README.md
|
47
36
|
- Rakefile
|
48
37
|
- capistrano-resque.gemspec
|
@@ -51,37 +40,27 @@ files:
|
|
51
40
|
- lib/capistrano-resque/version.rb
|
52
41
|
homepage: https://github.com/sshingler/capistrano-resque
|
53
42
|
licenses: []
|
54
|
-
|
55
43
|
post_install_message:
|
56
44
|
rdoc_options: []
|
57
|
-
|
58
|
-
require_paths:
|
45
|
+
require_paths:
|
59
46
|
- lib
|
60
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
48
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
66
|
-
|
67
|
-
- 0
|
68
|
-
version: "0"
|
69
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
54
|
none: false
|
71
|
-
requirements:
|
72
|
-
- -
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
segments:
|
76
|
-
- 0
|
77
|
-
version: "0"
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
78
59
|
requirements: []
|
79
|
-
|
80
60
|
rubyforge_project:
|
81
61
|
rubygems_version: 1.8.15
|
82
62
|
signing_key:
|
83
63
|
specification_version: 3
|
84
64
|
summary: Resque integration for Capistrano
|
85
65
|
test_files: []
|
86
|
-
|
87
66
|
has_rdoc:
|