stalk-boss 0.1.7 → 0.1.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/VERSION +1 -1
- data/lib/stalk_boss.rb +24 -10
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.8
|
data/lib/stalk_boss.rb
CHANGED
@@ -4,25 +4,38 @@ module Stalker
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def soft_quit=(soft_quit)
|
7
|
+
exit if !job_in_progress? && soft_quit
|
7
8
|
@soft_quit = soft_quit
|
8
9
|
end
|
9
10
|
|
11
|
+
def job_in_progress?
|
12
|
+
@in_progress ||= false
|
13
|
+
end
|
14
|
+
|
10
15
|
alias :work_one_job_stalker :work_one_job
|
11
|
-
|
16
|
+
alias :log_job_begin_stalker :log_job_begin
|
17
|
+
alias :log_job_end_stalker :log_job_end
|
18
|
+
|
12
19
|
def work_one_job
|
13
20
|
exit if soft_quit?
|
14
21
|
work_one_job_stalker
|
15
22
|
end
|
16
23
|
|
24
|
+
def log_job_begin(name, args)
|
25
|
+
@in_progress = true
|
26
|
+
log_job_begin_stalker(name, args)
|
27
|
+
end
|
28
|
+
|
29
|
+
def log_job_end(name, failed=false)
|
30
|
+
@in_progress = false
|
31
|
+
log_job_end_stalker(name, failed)
|
32
|
+
end
|
33
|
+
|
17
34
|
end
|
18
35
|
module StalkBoss
|
19
36
|
class Stalk
|
20
37
|
attr_accessor :pipes, :worker, :workers, :log
|
21
38
|
|
22
|
-
def pipes
|
23
|
-
@pipes ||= []
|
24
|
-
end
|
25
|
-
|
26
39
|
def initialize(worker, workers=1, log=nil)
|
27
40
|
super
|
28
41
|
@worker = worker
|
@@ -31,16 +44,17 @@ module StalkBoss
|
|
31
44
|
end
|
32
45
|
|
33
46
|
def pids
|
34
|
-
@
|
47
|
+
@pids ||= []
|
35
48
|
end
|
36
49
|
|
37
50
|
def start
|
38
51
|
(1..@workers).each do
|
39
|
-
|
52
|
+
pids << fork do
|
53
|
+
STDOUT.reopen(File.open(@log, 'a'))
|
54
|
+
exec 'bossed_stalk', @worker
|
55
|
+
end
|
40
56
|
end
|
41
57
|
end
|
42
|
-
|
43
|
-
|
44
58
|
end
|
45
59
|
|
46
60
|
def stalk_jobs
|
@@ -69,7 +83,7 @@ module StalkBoss
|
|
69
83
|
private
|
70
84
|
|
71
85
|
def send_signal(sig)
|
72
|
-
stalk_jobs.each do |s|
|
86
|
+
stalk_jobs.each do |s|
|
73
87
|
s.pids.each do |pid|
|
74
88
|
Process.kill sig, pid
|
75
89
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 8
|
9
|
+
version: 0.1.8
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ryan Dew
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-12 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|