sensu-spawn 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -3
- data/lib/sensu/spawn.rb +8 -5
- data/sensu-spawn.gemspec +1 -2
- data/spec/helpers.rb +0 -5
- data/spec/spawn_spec.rb +11 -0
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c59ce912fa389d190c82e3b8503bcd40f075826
|
4
|
+
data.tar.gz: 268adebe9265c982e1511840163175d4c88d615e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 766cf5892f5a83704a43f12b91b91a9c650de1c5bb1c8f4106983d50b54d6cd637ca4f5ce8beddc5c1e072e07bcb68cbbc6654eb47600338073c58df30754365
|
7
|
+
data.tar.gz: 53893f509cec1de5ab94047f3259aaebd1aa2bdddb8f7c902898795d79917d8d34ada61b90812d60357dad5931a969b52e99e68dc2dbcb86c36e9a5c549e1521
|
data/README.md
CHANGED
@@ -2,9 +2,6 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/sensu/sensu-spawn.svg?branch=master)](https://travis-ci.org/sensu/sensu-spawn)
|
4
4
|
|
5
|
-
[![Code Climate](https://codeclimate.com/github/sensu/sensu-spawn.png)](https://codeclimate.com/github/sensu/sensu-spawn)
|
6
|
-
[![Code Climate Coverage](https://codeclimate.com/github/sensu/sensu-spawn/coverage.png)](https://codeclimate.com/github/sensu/sensu-spawn)
|
7
|
-
|
8
5
|
## Installation
|
9
6
|
|
10
7
|
Add this line to your application's Gemfile:
|
data/lib/sensu/spawn.rb
CHANGED
@@ -5,6 +5,7 @@ require "eventmachine"
|
|
5
5
|
require "em/worker"
|
6
6
|
require "childprocess"
|
7
7
|
require "rbconfig"
|
8
|
+
require "timeout"
|
8
9
|
|
9
10
|
# Attempt an upfront loading of FFI and POSIX spawn libraries. These
|
10
11
|
# libraries may fail to load on certain platforms, load errors are
|
@@ -105,9 +106,9 @@ module Sensu
|
|
105
106
|
# so a mutex is used to allow safe execution on Ruby runtimes
|
106
107
|
# with real threads (JRuby).
|
107
108
|
#
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
109
|
+
# Using stdlib's Timeout instead of child.poll_for_exit to
|
110
|
+
# avoid a deadlock, when the child output is greater than
|
111
|
+
# the OS max buffer size.
|
111
112
|
#
|
112
113
|
# @param [String] command to run.
|
113
114
|
# @param [Hash] options to create a child process with.
|
@@ -126,8 +127,10 @@ module Sensu
|
|
126
127
|
child.io.stdin.close
|
127
128
|
end
|
128
129
|
if options[:timeout]
|
129
|
-
|
130
|
-
|
130
|
+
output = Timeout::timeout(options[:timeout], ChildProcess::TimeoutError) do
|
131
|
+
read_until_eof(reader)
|
132
|
+
end
|
133
|
+
child.wait
|
131
134
|
else
|
132
135
|
output = read_until_eof(reader)
|
133
136
|
child.wait
|
data/sensu-spawn.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "sensu-spawn"
|
5
|
-
spec.version = "2.
|
5
|
+
spec.version = "2.1.0"
|
6
6
|
spec.authors = ["Sean Porter"]
|
7
7
|
spec.email = ["portertech@gmail.com"]
|
8
8
|
spec.summary = "The Sensu spawn process library"
|
@@ -22,5 +22,4 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.6"
|
23
23
|
spec.add_development_dependency "rake", "10.5.0"
|
24
24
|
spec.add_development_dependency "rspec"
|
25
|
-
spec.add_development_dependency "codeclimate-test-reporter" unless RUBY_VERSION < "1.9"
|
26
25
|
end
|
data/spec/helpers.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
require "rspec"
|
2
2
|
require "eventmachine"
|
3
3
|
|
4
|
-
unless RUBY_VERSION < "1.9" || RUBY_PLATFORM =~ /java/
|
5
|
-
require "codeclimate-test-reporter"
|
6
|
-
CodeClimate::TestReporter.start
|
7
|
-
end
|
8
|
-
|
9
4
|
module Helpers
|
10
5
|
def timer(delay, &callback)
|
11
6
|
periodic_timer = EM::PeriodicTimer.new(delay) do
|
data/spec/spawn_spec.rb
CHANGED
@@ -30,6 +30,17 @@ describe "Sensu::Spawn" do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
it "can spawn a process with output greater than 64KB with a timeout" do |output, status|
|
34
|
+
output_asset = "spec/assets/output_1MB"
|
35
|
+
expected_output = IO.read(output_asset)
|
36
|
+
async_wrapper do
|
37
|
+
Sensu::Spawn.process("cat #{output_asset}", :timeout => 10) do |output, status|
|
38
|
+
expect(output).to eq(expected_output)
|
39
|
+
expect(status).to eq(0)
|
40
|
+
async_done
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
33
44
|
|
34
45
|
it "can spawn a process with a non-zero exit status" do
|
35
46
|
async_wrapper do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-spawn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -94,20 +94,6 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: codeclimate-test-reporter
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
97
|
description: The Sensu spawn process library
|
112
98
|
email:
|
113
99
|
- portertech@gmail.com
|