sweatshop 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/VERSION.yml +3 -2
- data/lib/message_queue/rabbit.rb +2 -0
- data/lib/sweatshop/sweatd.rb +10 -5
- data/lib/sweatshop/worker.rb +5 -1
- data/lib/sweatshop.rb +13 -5
- metadata +4 -4
data/Rakefile
CHANGED
@@ -9,11 +9,11 @@ begin
|
|
9
9
|
s.name = "sweatshop"
|
10
10
|
s.summary = %Q{Sweatshop is a simple asynchronous worker queue build on top of rabbitmq/ampq}
|
11
11
|
s.email = "amos@geni.com"
|
12
|
-
s.homepage = "http://github.com/famoseagle/
|
12
|
+
s.homepage = "http://github.com/famoseagle/sweatshop"
|
13
13
|
s.description = "See summary"
|
14
14
|
s.authors = ["Amos Elliston"]
|
15
15
|
s.files = FileList["[A-Z]*", "install.rb", "{lib,test,config,script}/**/*"]
|
16
|
-
s.add_dependency('
|
16
|
+
s.add_dependency('carrot', '= 0.7.0')
|
17
17
|
end
|
18
18
|
Jeweler::GemcutterTasks.new
|
19
19
|
rescue LoadError
|
data/VERSION.yml
CHANGED
data/lib/message_queue/rabbit.rb
CHANGED
data/lib/sweatshop/sweatd.rb
CHANGED
@@ -34,11 +34,14 @@ module Sweatshop
|
|
34
34
|
end
|
35
35
|
|
36
36
|
sig(:hup) do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
begin
|
38
|
+
puts "Received HUP"
|
39
|
+
Sweatshop.stop
|
40
|
+
ensure
|
41
|
+
remove_pid!
|
42
|
+
puts "Restarting sweatd with #{start_cmd}..."
|
43
|
+
`#{start_cmd}`
|
44
|
+
end
|
42
45
|
end
|
43
46
|
|
44
47
|
before do
|
@@ -52,6 +55,8 @@ module Sweatshop
|
|
52
55
|
daemonize(:kill_timeout => 20) do
|
53
56
|
workers = []
|
54
57
|
|
58
|
+
Sweatshop.daemonize
|
59
|
+
|
55
60
|
if groups.any?
|
56
61
|
workers += Sweatshop.workers_in_group(groups)
|
57
62
|
end
|
data/lib/sweatshop/worker.rb
CHANGED
data/lib/sweatshop.rb
CHANGED
@@ -79,6 +79,14 @@ module Sweatshop
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
def daemon?
|
83
|
+
@daemon
|
84
|
+
end
|
85
|
+
|
86
|
+
def daemonize
|
87
|
+
@daemon = true
|
88
|
+
end
|
89
|
+
|
82
90
|
def stop
|
83
91
|
@stop = true
|
84
92
|
end
|
@@ -114,7 +122,7 @@ module Sweatshop
|
|
114
122
|
end
|
115
123
|
|
116
124
|
def queue_groups
|
117
|
-
@queue_groups ||= workers.collect{|w| w.queue_group} << 'default'
|
125
|
+
@queue_groups ||= (workers.collect{|w| w.queue_group.to_s} << 'default').uniq
|
118
126
|
end
|
119
127
|
|
120
128
|
def pp_sizes
|
@@ -132,18 +140,18 @@ module Sweatshop
|
|
132
140
|
next unless qconfig['cluster']
|
133
141
|
servers << qconfig['cluster']
|
134
142
|
end
|
135
|
-
servers.flatten
|
143
|
+
servers = servers.flatten.uniq
|
136
144
|
|
137
145
|
servers.each do |server|
|
138
146
|
puts "\nQueue sizes on #{server}"
|
139
147
|
queue = MessageQueue::Rabbit.new('host' => server)
|
140
|
-
|
141
|
-
|
148
|
+
workers.each do |worker|
|
149
|
+
worker.queue = queue
|
142
150
|
end
|
143
151
|
pp_sizes
|
144
152
|
puts
|
145
153
|
end
|
146
|
-
|
154
|
+
workers.each{|w| w.queue = nil}
|
147
155
|
nil
|
148
156
|
end
|
149
157
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sweatshop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amos Elliston
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-03 00:00:00 -08:00
|
13
13
|
default_executable: sweatd
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: carrot
|
17
17
|
type: :runtime
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -57,7 +57,7 @@ files:
|
|
57
57
|
- test/test_helper.rb
|
58
58
|
- test/test_sweatshop.rb
|
59
59
|
has_rdoc: true
|
60
|
-
homepage: http://github.com/famoseagle/
|
60
|
+
homepage: http://github.com/famoseagle/sweatshop
|
61
61
|
licenses: []
|
62
62
|
|
63
63
|
post_install_message:
|