ost-bin 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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Mzg5YjIyZTAxMTliOTFjYTE4NWI2MGUwNTMxNWU4MjY2ZjExMDU0YQ==
4
+ YTBlZDRlZDNjZGEwMjY0Zjk4N2VlMDI2ZjgxNjMyY2RjYmE4YzhmMg==
5
5
  data.tar.gz: !binary |-
6
- MzI1ZWRhNmE2NDJlOWZkMTZiZjBlZWUwOGU4MjBjMDNiYzY0YmM4NA==
6
+ NzFkNmJhYWVhNWZmNzliMWZmNTRjZWU5NmQ0MTk5ZDliZDZlMzYwOQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MWJhNGNhYzZlNzBhMWI2OTk2OGYwN2U4Y2IzODA4ODM5ZGJhZjcwMWZmNTJh
10
- M2E2ZTI2YmZmMjhhN2IxNjA0NzFkMDQ0MmMyNjRkNGY4ZjliODBlMzA2ZDRi
11
- OTc5NWM0OWI0M2Q4NDNkOTkyOTliZjYxYzA1ZTBlZWE3NTUyYzg=
9
+ MTliMGY4YjJkZmZmYmJjZGUzYjY0ODRmY2Q4MGUwYTEyYmIzMjQ3YWYzNTYw
10
+ YzgwMzgyNDZjNzMyOTlkN2VkNzAyNTNiN2FiOWJlODQ5ZGI2M2VjYmEwMzRi
11
+ ZDQxNTU2OWZiYmU0OGU2YzFhMzYxYjM0OTBlNWJjNDllNWZlYmI=
12
12
  data.tar.gz: !binary |-
13
- MzQ3MDUxYWQ1YTIzN2QwNjA5NGNlMzMyZTk5NDEzNzc5YTFlZjlhYTE4ZGJk
14
- YmJlMWMyYTM4NjkzMmViM2NlNTkzNGQwYTk0M2M2MWFlMWVjNWJiZWY2MTYy
15
- OWY0NmQ4OGVlNGExMTMwY2ViMjhjMDI4ZDM3YjY1ZDk3NzhmOWY=
13
+ NTEwNTEyNTZmZWFkYWU4OGRlMWMzYTYwZmY2MTgzNDBiOGY3MzM5MjJhYzNm
14
+ NGQ4MjFhYzgzN2IyYmIwNjE1YTI3OWM3MDQ1YzdlNDdkMTRlNGMzNDhjYmNh
15
+ ZWU1YzRiYzEzNDg2ZTkxNWRmYTQ1YmYzZTI3ODY1NTAzZTMwM2I=
@@ -1,3 +1,8 @@
1
+ # 0.1.1 - 2014-07-23
2
+
3
+ * When daemonized, all output is now redirected to a file. It's `ost.log` by
4
+ default, but you can specify a different path via `-l`.
5
+
1
6
  # 0.1.0 - 2014-05-26
2
7
 
3
8
  * Moved to a threaded model.
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)
@@ -1,5 +1,5 @@
1
1
  require "ost"
2
2
 
3
3
  module Ost::Bin
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
@@ -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.0
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-05-26 00:00:00.000000000 Z
11
+ date: 2014-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ost