svcdeps_tasks 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 389eec8a9b2950defc3f874df209d27791a0a429
4
- data.tar.gz: '09f8bc57702f78fc4c8a42ed085068062c4648bc'
3
+ metadata.gz: 189a17aee33cca4ac7d2a52861f80587818d1620
4
+ data.tar.gz: cb3474712b034c272dd5f335cd9f84eeefdaa0b2
5
5
  SHA512:
6
- metadata.gz: fd9929599470f5b0d1f11edb2e42da7a4590e7941e79d7372995d137d76881d782fdd435a1556c8f34a166a34d831de065b65e2ede2a57ef9d43d196254b8149
7
- data.tar.gz: 401e7c1d0d10085407af16bdf13b6914e83c3aa2689c00a3300d9c324f97ef340ea41979a4a814d2d1c700c2430d0c0f62b53638b0ba17a47bd4197c2acca33a
6
+ metadata.gz: 986c58d3346e894254b56b08392ea2684b714b718f5cdfa87db36127ff55ce85a7092f28d9ef905d09b86766bdd8930849c18940b39aba5a7781122af6a5a473
7
+ data.tar.gz: b3911923d3ae6c5e67eaac0a2ae5cb7673da1f2ba3ccc56a50236d4a3b24957ad26a61f2c01886cfdce11250e756bca0cede3cdc1989feb827658b04f820aa57
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- svcdeps_tasks (0.1.5)
4
+ svcdeps_tasks (0.1.6)
5
5
  deep_merge (~> 1.2)
6
6
  rspec (~> 3.7)
7
7
 
data/lib/probe.rb CHANGED
@@ -40,8 +40,8 @@ class Probe
40
40
  run_as = nil unless Process.uid.zero?
41
41
  end
42
42
 
43
- Timeout::timeout(@timeout) do
44
- user = Etc.getpwnam(run_as)
43
+ Timeout::timeout(@timeout) do
44
+ user = Etc.getpwnam(run_as) if run_as
45
45
  pid = Process.fork do
46
46
  STDOUT.reopen('/dev/null')
47
47
  STDERR.reopen('/dev/null')
@@ -100,16 +100,26 @@ class Probe
100
100
  end
101
101
  end
102
102
 
103
+ def error_wrapper(&block)
104
+ begin
105
+ instance_eval(&block) if block_given?
106
+ raise 'block should be passed to error_wrapper' unless block_given?
107
+ rescue => e
108
+ return "#{e.class} => #{e.message}"
109
+ end
110
+ "SUCCESS"
111
+ end
112
+
103
113
  def run
104
114
  case @type
105
115
  when 'tcp'
106
- tcp_probe
116
+ error_wrapper { tcp_probe }
107
117
  when 'udp'
108
- udp_probe
118
+ error_wrapper { udp_probe }
109
119
  when 'command'
110
- command_probe
120
+ error_wrapper { command_probe }
111
121
  when 'http'
112
- http_probe
122
+ error_wrapper { http_probe }
113
123
  else
114
124
  raise "Type '#{@type}' not supported"
115
125
  end
data/lib/specfile.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rspec'
2
+
2
3
  set :backend, :exec
3
4
 
4
5
  dir = File.dirname(File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__)
@@ -30,7 +31,7 @@ describe 'Service Dependencies' do
30
31
  dep = symbolize_keys(dep)
31
32
  it "#{dep[:desc]}" do
32
33
  p = Probe.new( dep )
33
- expect { p.run }.to_not raise_error
34
+ expect(p.run) == 'SUCCESS'
34
35
  end
35
36
  end if deps['deps']
36
37
  end
@@ -1,3 +1,3 @@
1
1
  module SvcdepsTasks
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svcdeps_tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Lopo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-10 00:00:00.000000000 Z
11
+ date: 2018-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec