ost-bin 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +5 -0
- data/bin/ost +10 -1
- data/lib/ost-bin/version.rb +1 -1
- data/test/bin.rb +58 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTBlZDRlZDNjZGEwMjY0Zjk4N2VlMDI2ZjgxNjMyY2RjYmE4YzhmMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzFkNmJhYWVhNWZmNzliMWZmNTRjZWU5NmQ0MTk5ZDliZDZlMzYwOQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTliMGY4YjJkZmZmYmJjZGUzYjY0ODRmY2Q4MGUwYTEyYmIzMjQ3YWYzNTYw
|
10
|
+
YzgwMzgyNDZjNzMyOTlkN2VkNzAyNTNiN2FiOWJlODQ5ZGI2M2VjYmEwMzRi
|
11
|
+
ZDQxNTU2OWZiYmU0OGU2YzFhMzYxYjM0OTBlNWJjNDllNWZlYmI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTEwNTEyNTZmZWFkYWU4OGRlMWMzYTYwZmY2MTgzNDBiOGY3MzM5MjJhYzNm
|
14
|
+
NGQ4MjFhYzgzN2IyYmIwNjE1YTI3OWM3MDQ1YzdlNDdkMTRlNGMzNDhjYmNh
|
15
|
+
ZWU1YzRiYzEzNDg2ZTkxNWRmYTQ1YmYzZTI3ODY1NTAzZTMwM2I=
|
data/CHANGELOG.md
CHANGED
data/bin/ost
CHANGED
@@ -14,7 +14,7 @@ trap(:TERM, &stop)
|
|
14
14
|
usage = <<-EOS
|
15
15
|
Usage:
|
16
16
|
|
17
|
-
ost start [-r <require>] [-d] [-p <pid-path>]
|
17
|
+
ost start [-r <require>] [-d] [-p <pid-path>] [-l <log-path>]
|
18
18
|
ost stop [-p <pid-path>]
|
19
19
|
|
20
20
|
EOS
|
@@ -29,6 +29,10 @@ opts = {
|
|
29
29
|
command, _ = Clap.run ARGV,
|
30
30
|
"-d" => -> {
|
31
31
|
opts[:daemonize] = true
|
32
|
+
opts[:log_path] = File.expand_path("ost.log") unless opts.include?(:log_path)
|
33
|
+
},
|
34
|
+
"-l" => -> path {
|
35
|
+
opts[:log_path] = path
|
32
36
|
},
|
33
37
|
"-p" => -> path {
|
34
38
|
opts[:pid_path] = path
|
@@ -81,6 +85,11 @@ when "start"
|
|
81
85
|
end
|
82
86
|
end
|
83
87
|
|
88
|
+
if opts[:log_path]
|
89
|
+
$stdout.reopen(opts[:log_path], "a")
|
90
|
+
$stderr.reopen(opts[:log_path], "a")
|
91
|
+
end
|
92
|
+
|
84
93
|
load "./Ostfile"
|
85
94
|
|
86
95
|
opts[:pool_size] = Ost.workers.size unless opts.include?(:pool_size)
|
data/lib/ost-bin/version.rb
CHANGED
data/test/bin.rb
CHANGED
@@ -172,3 +172,61 @@ test "load Ostfile" do
|
|
172
172
|
Process.kill(:INT, pid) if pid
|
173
173
|
end
|
174
174
|
end
|
175
|
+
|
176
|
+
test "redirect stdout and stderr to a log file when daemonizing" do
|
177
|
+
pid, detached_pid = nil
|
178
|
+
|
179
|
+
pid_path = "./test/workers/logger/ost.pid"
|
180
|
+
|
181
|
+
log_path = "test/workers/logger/ost.log"
|
182
|
+
|
183
|
+
File.delete(log_path) if File.exist?(log_path)
|
184
|
+
|
185
|
+
begin
|
186
|
+
pid = spawn("#{root("bin/ost")} -d start", chdir: "test/workers/logger")
|
187
|
+
|
188
|
+
assert wait_for {
|
189
|
+
`ps -p #{pid} -o state`.lines.to_a.last[/(\w+)/, 1] == "Z"
|
190
|
+
}
|
191
|
+
|
192
|
+
redis.lpush("ost:Logger", 1)
|
193
|
+
ensure
|
194
|
+
detached_pid = read_pid_file(pid_path)
|
195
|
+
|
196
|
+
Process.kill(:INT, pid) if pid
|
197
|
+
Process.kill(:INT, detached_pid) if detached_pid
|
198
|
+
end
|
199
|
+
|
200
|
+
wait_for_pid(detached_pid)
|
201
|
+
|
202
|
+
assert_equal "out: 1\nerr: 1\n", File.read(log_path)
|
203
|
+
end
|
204
|
+
|
205
|
+
test "redirect stdout and stderr to a different log file when daemonizing" do
|
206
|
+
pid, detached_pid = nil
|
207
|
+
|
208
|
+
pid_path = "./test/workers/logger/ost.pid"
|
209
|
+
|
210
|
+
log_path = "test/workers/logger/foo.log"
|
211
|
+
|
212
|
+
File.delete(log_path) if File.exist?(log_path)
|
213
|
+
|
214
|
+
begin
|
215
|
+
pid = spawn("#{root("bin/ost")} -d -l foo.log start", chdir: "test/workers/logger")
|
216
|
+
|
217
|
+
assert wait_for {
|
218
|
+
`ps -p #{pid} -o state`.lines.to_a.last[/(\w+)/, 1] == "Z"
|
219
|
+
}
|
220
|
+
|
221
|
+
redis.lpush("ost:Logger", 1)
|
222
|
+
ensure
|
223
|
+
detached_pid = read_pid_file(pid_path)
|
224
|
+
|
225
|
+
Process.kill(:INT, pid) if pid
|
226
|
+
Process.kill(:INT, detached_pid) if detached_pid
|
227
|
+
end
|
228
|
+
|
229
|
+
wait_for_pid(detached_pid)
|
230
|
+
|
231
|
+
assert_equal "out: 1\nerr: 1\n", File.read(log_path)
|
232
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ost-bin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damian Janowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ost
|