capistrano-resque 0.0.2 → 0.0.3
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.lock +1 -1
- data/README.md +16 -3
- data/lib/capistrano-resque/capistrano_integration.rb +29 -7
- data/lib/capistrano-resque/version.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Capistrano Resque
|
2
2
|
|
3
|
+
Basic tasks for putting some Resque in your Cap.
|
4
|
+
|
3
5
|
### In your Capfile:
|
4
6
|
|
5
7
|
```
|
@@ -17,6 +19,17 @@ Then, running cap -vT | grep resque should give you...
|
|
17
19
|
|
18
20
|
```
|
19
21
|
➔ cap -vT | grep resque
|
20
|
-
cap resque:
|
21
|
-
cap resque:
|
22
|
-
|
22
|
+
cap resque:start # Start Resque workers
|
23
|
+
cap resque:stop # Quit running Resque workers
|
24
|
+
cap resque:restart # Restart running Resque workers
|
25
|
+
```
|
26
|
+
|
27
|
+
### Restart on deployer
|
28
|
+
|
29
|
+
To restart you workers automatically when `cap deploy:restart` is executed
|
30
|
+
add the following line to your `deploy.rb`:
|
31
|
+
|
32
|
+
```
|
33
|
+
after "deploy:restart", "resque:restart"
|
34
|
+
```
|
35
|
+
|
@@ -19,35 +19,57 @@ module CapistranoResque
|
|
19
19
|
capture("ps -p $(cat #{pid_file}) ; true").strip.split("\n").size == 2
|
20
20
|
end
|
21
21
|
|
22
|
+
def current_pids
|
23
|
+
capture("ls #{current_path}/tmp/pids/resque_work*.pid").strip.split(/\r{0,1}\n/)
|
24
|
+
end
|
25
|
+
|
22
26
|
namespace :resque do
|
27
|
+
desc "See current worker status"
|
28
|
+
task :status do
|
29
|
+
current_pids.each do |pid|
|
30
|
+
if remote_file_exists?(pid)
|
31
|
+
if remote_process_exists?(pid)
|
32
|
+
logger.important("Up and running", "Resque Worker: #{pid}")
|
33
|
+
else
|
34
|
+
logger.important("Down", "Resque Worker: #{pid}")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
23
40
|
desc "Start Resque workers"
|
24
|
-
task :
|
41
|
+
task :start do
|
25
42
|
puts "Starting #{num_of_queues} worker(s) with QUEUE: #{queue_name}"
|
26
43
|
num_of_queues.times do |i|
|
27
44
|
pid = "./tmp/pids/resque_worker_#{i}.pid"
|
28
45
|
run "cd #{current_path} && RAILS_ENV=#{app_env} QUEUE=#{queue_name} \
|
29
|
-
PIDFILE=#{pid} BACKGROUND=yes LOGFILE=./resque-worker#{i}.log VVERBOSE=#{verbosity} \
|
46
|
+
PIDFILE=#{pid} BACKGROUND=yes LOGFILE=./log/resque-worker#{i}.log VVERBOSE=#{verbosity} \
|
30
47
|
bundle exec rake environment resque:work"
|
31
48
|
end
|
32
49
|
end
|
33
50
|
|
34
51
|
desc "Quit running Resque workers"
|
35
|
-
task :
|
36
|
-
|
37
|
-
pid = "#{current_path}/tmp/pids/resque_worker_#{i}.pid"
|
52
|
+
task :stop do
|
53
|
+
current_pids.each do |pid|
|
38
54
|
if remote_file_exists?(pid)
|
39
55
|
if remote_process_exists?(pid)
|
40
|
-
logger.important("Stopping...", "Resque Worker #{
|
56
|
+
logger.important("Stopping...", "Resque Worker: #{pid}")
|
41
57
|
run "#{try_sudo} kill `cat #{pid}`"
|
42
58
|
else
|
43
59
|
run "rm #{pid}"
|
44
|
-
logger.important("Resque Worker #{
|
60
|
+
logger.important("Resque Worker #{pid} is not running.", "Resque")
|
45
61
|
end
|
46
62
|
else
|
47
63
|
logger.important("No PIDs found. Check if Resque is running.", "Resque")
|
48
64
|
end
|
49
65
|
end
|
50
66
|
end
|
67
|
+
|
68
|
+
desc "Restart running Resque workers"
|
69
|
+
task :restart do
|
70
|
+
stop
|
71
|
+
start
|
72
|
+
end
|
51
73
|
end
|
52
74
|
end
|
53
75
|
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:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
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-
|
18
|
+
date: 2012-06-12 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: capistrano
|