hookit 0.10.0 → 0.11.0
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 +4 -4
- data/lib/hookit/platform.rb +1 -1
- data/lib/hookit/resource/execute.rb +41 -14
- data/lib/hookit/resource/service.rb +1 -6
- data/lib/hookit/resource/socket.rb +4 -4
- data/lib/hookit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ef6a1d03fe66b7dc858921b2c6f9b38c46dab67
|
4
|
+
data.tar.gz: 11ab5f5d41b157edbd05903ee92714bee86fae0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 695084242a78005016c86fbf9e26903e631bb2c1f6fe2a1094eac62a75a1f26cc077fc2f3a667ba3a048bfccc97c0b806d541f4091608c644acbaba2260c11bc
|
7
|
+
data.tar.gz: 177d445bc16ad1ec7fef87be550b105259a47f5b890f9923fac8e409ec56fece6a14e42f29356161716dc54e6dbff756550023ebb66477bc17d0045b2f9d960e
|
data/lib/hookit/platform.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'timeout'
|
2
|
+
require 'open3'
|
2
3
|
|
3
4
|
module Hookit
|
4
5
|
module Resource
|
@@ -13,6 +14,8 @@ module Hookit
|
|
13
14
|
field :timeout
|
14
15
|
field :stream
|
15
16
|
field :on_data
|
17
|
+
field :on_stdout
|
18
|
+
field :on_stderr
|
16
19
|
field :on_exit
|
17
20
|
field :validator
|
18
21
|
field :ignore_exit
|
@@ -66,31 +69,55 @@ module Hookit
|
|
66
69
|
end
|
67
70
|
|
68
71
|
def stream!
|
72
|
+
exit_status = 0
|
69
73
|
result = ""
|
70
74
|
|
71
75
|
STDOUT.sync = STDERR.sync = true # don't buffer stdout/stderr
|
72
76
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
Open3.popen3 cmd do |stdin, stdout, stderr, wait_thr|
|
78
|
+
stdout_eof = false
|
79
|
+
stderr_eof = false
|
80
|
+
|
81
|
+
until stdout_eof and stderr_eof do
|
82
|
+
(ready_pipes, dummy, dummy) = IO.select([stdout, stderr])
|
83
|
+
ready_pipes.each_with_index do |socket|
|
84
|
+
if socket == stdout
|
85
|
+
begin
|
86
|
+
chunk = socket.readpartial(4096)
|
87
|
+
if on_data and on_data.respond_to? :call
|
88
|
+
on_data.call(chunk)
|
89
|
+
end
|
90
|
+
if on_stdout and on_stdout.respond_to? :call
|
91
|
+
on_stdout.call(chunk)
|
92
|
+
end
|
93
|
+
rescue EOFError
|
94
|
+
stdout_eof = true
|
95
|
+
end
|
96
|
+
result << chunk.to_s
|
97
|
+
elsif socket == stderr
|
98
|
+
begin
|
99
|
+
chunk = socket.readpartial(4096)
|
100
|
+
if on_data and on_data.respond_to? :call
|
101
|
+
on_data.call(chunk)
|
102
|
+
end
|
103
|
+
if on_stderr and on_stderr.respond_to? :call
|
104
|
+
on_stderr.call(chunk)
|
105
|
+
end
|
106
|
+
rescue EOFError
|
107
|
+
stderr_eof = true
|
108
|
+
end
|
109
|
+
result << chunk.to_s
|
80
110
|
end
|
81
|
-
rescue EOFError
|
82
|
-
eof = true
|
83
111
|
end
|
84
|
-
result << chunk.to_s
|
85
112
|
end
|
86
|
-
end
|
87
113
|
|
88
|
-
|
114
|
+
exit_status = wait_thr.value.to_s.match(/exit (\d+)/)[1].to_i
|
115
|
+
end
|
89
116
|
|
90
117
|
if on_exit and on_exit.respond_to? :call
|
91
|
-
on_exit.call(
|
118
|
+
on_exit.call(exit_status)
|
92
119
|
else
|
93
|
-
unexpected_exit(
|
120
|
+
unexpected_exit(exit_status) unless exit_status == returns
|
94
121
|
end
|
95
122
|
|
96
123
|
validate! result
|
@@ -49,11 +49,6 @@ module Hookit
|
|
49
49
|
when :smf
|
50
50
|
run_command! "svcadm enable -s #{"-r" if recursive} #{service_name}"
|
51
51
|
when :runit
|
52
|
-
# fail fast if we don't have an runit run configuration
|
53
|
-
if not File.exist?("/etc/service/#{service_name}/run")
|
54
|
-
raise Hookit::Error::MissingConfiguration "Expecting service configuration file at: /etc/service/#{service_name}/run"
|
55
|
-
end
|
56
|
-
|
57
52
|
# register and potentially start the service
|
58
53
|
run_command! "sv start #{service_name}", false
|
59
54
|
|
@@ -119,4 +114,4 @@ module Hookit
|
|
119
114
|
|
120
115
|
end
|
121
116
|
end
|
122
|
-
end
|
117
|
+
end
|
@@ -17,11 +17,11 @@ module Hookit
|
|
17
17
|
|
18
18
|
case platform.os
|
19
19
|
when 'sun'
|
20
|
-
@active_com
|
21
|
-
@inactive_com
|
20
|
+
@active_com = "netstat -an | egrep '\*\.#{port}' | grep LISTEN"
|
21
|
+
@inactive_com = "netstat -an | grep 'ESTABLISHED' | awk '{ print $1 }' | grep \"$(ifconfig #{interface} | grep inet | awk '{ print $2 }')\.#{port}\""
|
22
22
|
else
|
23
|
-
@active_com
|
24
|
-
@inactive_com
|
23
|
+
@active_com = "netstat -an | egrep ':#{port}' | grep LISTEN"
|
24
|
+
@inactive_com = "netstat -an | grep 'ESTABLISHED' | awk '{ print $4 }' | grep \"$(ifconfig #{interface} | awk '/inet addr/ { print $2}' | cut -f2 -d':' | tr -d '\n'):#{port}\""
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
data/lib/hookit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hookit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Flint
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-09-
|
12
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tilt
|