fluent-exec 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/fluent-exec.gemspec CHANGED
@@ -8,9 +8,10 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Fluent::Exec::VERSION
9
9
  gem.authors = ["Takenari Shinohara"]
10
10
  gem.email = ["takenari.shinohara@gmail.com"]
11
- gem.description = "Log command's exit status, output and runtime to fluentd."
12
- gem.summary = "Log command's exit status, output and runtime to fluentd."
11
+ gem.description = "Execute Command and log exit status, output and runtime to fluentd."
12
+ gem.summary = "Execute Command and log exit status, output and runtime to fluentd."
13
13
  gem.homepage = "https://github.com/tshinohara/fluent-exec"
14
+ gem.required_ruby_version = "~>1.9.1"
14
15
 
15
16
  gem.files = `git ls-files`.split($/)
16
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
data/lib/fluent-exec.rb CHANGED
@@ -38,6 +38,16 @@ module Fluent
38
38
  exit 1
39
39
  end
40
40
  end
41
+
42
+ def io_copy_thr(from, to, str=nil)
43
+ Thread.new do
44
+ while s = from.read(1024)
45
+ to.write s
46
+ str << s if str
47
+ end
48
+ to.close
49
+ end
50
+ end
41
51
 
42
52
  def exec
43
53
  env = {}
@@ -48,26 +58,9 @@ module Fluent
48
58
  begin_time = Time.now
49
59
  sin, sout, serr, thr = Open3.popen3(env, *@cmd)
50
60
 
51
- sin_t = Thread.new do
52
- while s = $stdin.read(1024)
53
- sin.write s
54
- end
55
- sin.close
56
- end
57
-
58
- sout_t = Thread.new do
59
- while s = sout.read(1024)
60
- out_str << s
61
- $stdout.write s
62
- end
63
- end
64
-
65
- serr_t = Thread.new do
66
- while s = serr.read(1024)
67
- err_str << s
68
- $stderr.write s
69
- end
70
- end
61
+ sin_t = io_copy_thr $stdin, sin
62
+ sout_t = io_copy_thr sout, $stdout, out_str
63
+ serr_t = io_copy_thr serr, $stderr, err_str
71
64
 
72
65
  status = thr.value
73
66
  end_time = Time.now
@@ -87,9 +80,6 @@ module Fluent
87
80
  def run(args)
88
81
  parse! args
89
82
  record = exec
90
- #コマンドの実行を優先?
91
- #fluentdサーバに接続できない場合はどうする?
92
- # failover (file|stdout)?
93
83
  begin
94
84
  log = Fluent::Logger::FluentLogger.new(nil, :host => @host, :port => @port)
95
85
  log.post @tag, record
@@ -1,5 +1,5 @@
1
1
  module Fluent
2
2
  module Exec
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-exec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -27,7 +27,7 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.4.3
30
- description: Log command's exit status, output and runtime to fluentd.
30
+ description: Execute Command and log exit status, output and runtime to fluentd.
31
31
  email:
32
32
  - takenari.shinohara@gmail.com
33
33
  executables:
@@ -53,9 +53,9 @@ require_paths:
53
53
  required_ruby_version: !ruby/object:Gem::Requirement
54
54
  none: false
55
55
  requirements:
56
- - - ! '>='
56
+ - - ~>
57
57
  - !ruby/object:Gem::Version
58
- version: '0'
58
+ version: 1.9.1
59
59
  required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  none: false
61
61
  requirements:
@@ -67,6 +67,6 @@ rubyforge_project:
67
67
  rubygems_version: 1.8.23
68
68
  signing_key:
69
69
  specification_version: 3
70
- summary: Log command's exit status, output and runtime to fluentd.
70
+ summary: Execute Command and log exit status, output and runtime to fluentd.
71
71
  test_files: []
72
72
  has_rdoc: