stalk-boss 0.1.0 → 0.1.1
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/VERSION +1 -1
- data/lib/stalk_boss.rb +26 -10
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/stalk_boss.rb
CHANGED
@@ -17,22 +17,30 @@ module Stalker
|
|
17
17
|
end
|
18
18
|
module StalkBoss
|
19
19
|
class Stalk
|
20
|
-
attr_accessor :
|
20
|
+
attr_accessor :pipes, :worker, :workers, :log
|
21
21
|
|
22
|
-
def
|
22
|
+
def pipes
|
23
|
+
@pipes ||= []
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(worker, workers=1, log=nil)
|
23
27
|
super
|
24
|
-
@worker
|
25
|
-
@
|
28
|
+
@worker = worker
|
29
|
+
@workers = workers
|
30
|
+
@log = log
|
26
31
|
end
|
27
32
|
|
28
|
-
def
|
29
|
-
@
|
33
|
+
def pids
|
34
|
+
@pipes.map(&:pid) unless @pipe.nil?
|
30
35
|
end
|
31
36
|
|
32
37
|
def start
|
33
|
-
|
38
|
+
(1..@workers).each do
|
39
|
+
@pipes << IO.popen("bossed_stalk #{@worker} #{@log}")
|
40
|
+
end
|
34
41
|
end
|
35
42
|
|
43
|
+
|
36
44
|
end
|
37
45
|
|
38
46
|
def stalk_jobs
|
@@ -40,18 +48,26 @@ module StalkBoss
|
|
40
48
|
end
|
41
49
|
|
42
50
|
def stalk_job(worker, options={}, &block)
|
43
|
-
stalk = Stalk.new(worker, options[:log])
|
51
|
+
stalk = Stalk.new(worker, options[:workers], options[:log])
|
44
52
|
yield(stalk) if block_given?
|
45
53
|
stalk_jobs << stalk
|
46
54
|
stalk
|
47
55
|
end
|
48
56
|
|
49
57
|
def term
|
50
|
-
stalk_jobs.each
|
58
|
+
stalk_jobs.each do |s|
|
59
|
+
s.pids.each do |pid|
|
60
|
+
Process.kill 'INT', pid
|
61
|
+
end
|
62
|
+
end
|
51
63
|
end
|
52
64
|
|
53
65
|
def soft_quit
|
54
|
-
stalk_jobs.each
|
66
|
+
stalk_jobs.each do |s|
|
67
|
+
s.pids.each do |pid|
|
68
|
+
Process.kill 'QUIT', pid
|
69
|
+
end
|
70
|
+
end
|
55
71
|
end
|
56
72
|
|
57
73
|
def start
|