kommando 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/bin/matrix +19 -0
- data/bin/release +2 -2
- data/demos/ping_monitor.rb +11 -0
- data/docker-compose.yml +1 -1
- data/docker/Dockerfile.alpine +1 -1
- data/docker/Dockerfile.alpine-2.1 +1 -1
- data/docker/Dockerfile.alpine-2.2 +1 -1
- data/docker/Dockerfile.alpine-2.3 +1 -1
- data/docker/Dockerfile.debian +1 -1
- data/examples/redis_workaround.rb +30 -0
- data/lib/kommando.rb +6 -1
- data/lib/kommando/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a2293ea68b1d7c3e6fd7e3045a87aad8aee5ca3
|
4
|
+
data.tar.gz: ac8e7fcad1629c33147e8cbd637e30843758ba02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f6e2bd07f08f2cc30977bb704ecf475e4e47b8b6552f24ffc13ed7a134973c81e01dff32bd52f49d5acb23e59365e05da0c50861925a5c8a26a176edb0ca67d
|
7
|
+
data.tar.gz: b3683acec3ee38045cb8348bb58ccc011dc7f6fc6a7eef0357376405ae91a20b7ef5164c682c3ed95d174b732e71b4d36481b542f99cc97912ea760f8b7a7be2
|
data/CHANGELOG.md
CHANGED
data/bin/matrix
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
require "./lib/kommando"
|
4
4
|
require "yaml"
|
5
|
+
loops=if ARGV[0]
|
6
|
+
ARGV[0].to_i
|
7
|
+
else
|
8
|
+
-1
|
9
|
+
end
|
5
10
|
|
6
11
|
docker_compose=YAML.load(File.read("docker-compose.yml"))
|
7
12
|
services = docker_compose["services"].keys
|
@@ -19,17 +24,31 @@ for service in services
|
|
19
24
|
ks << k
|
20
25
|
end
|
21
26
|
|
27
|
+
def cleanup(ks)
|
28
|
+
ks.map(&:kill)
|
29
|
+
Kommando.run "docker-compose down"
|
30
|
+
end
|
31
|
+
|
22
32
|
loop do
|
33
|
+
puts "loops: #{loops}"
|
34
|
+
loops = loops - 1
|
35
|
+
|
23
36
|
for k in ks do
|
24
37
|
cmd=k.instance_variable_get(:@cmd)
|
25
38
|
puts "#{cmd} (#{(k.code ? "STOP" : "RUNNING")})"
|
26
39
|
|
27
40
|
if k.code
|
28
41
|
puts k.out
|
42
|
+
cleanup(ks)
|
29
43
|
exit 1
|
30
44
|
end
|
31
45
|
end
|
32
46
|
|
33
47
|
print "-"*20; puts " #{DateTime.now.to_s}"
|
34
48
|
sleep 2
|
49
|
+
|
50
|
+
if loops == 0
|
51
|
+
cleanup(ks)
|
52
|
+
exit 0
|
53
|
+
end
|
35
54
|
end
|
data/bin/release
CHANGED
data/demos/ping_monitor.rb
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# $ ruby demos/ping_monitor.rb
|
2
|
+
# 0.077 xxxxxxxxxxxxxxxxxxxxxxx
|
3
|
+
# 0.021 xxxxxx
|
4
|
+
# 0.027 xxxxxxxx
|
5
|
+
# 0.021 xxxxxx
|
6
|
+
# 0.021 xxxxxx
|
7
|
+
# 0.041 xxxxxxxxxxxx
|
8
|
+
# 0.021 xxxxxx
|
9
|
+
# 0.023 xxxxxx
|
10
|
+
# ^C
|
11
|
+
|
1
12
|
require "./lib/kommando"
|
2
13
|
|
3
14
|
k = Kommando.new "ping -i 0.2 127.0.0.1"
|
data/docker-compose.yml
CHANGED
data/docker/Dockerfile.alpine
CHANGED
data/docker/Dockerfile.debian
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require "./lib/kommando"
|
2
|
+
|
3
|
+
k = Kommando.new "redis-cli --raw", {
|
4
|
+
output: true
|
5
|
+
}
|
6
|
+
|
7
|
+
# redis sends cursor position queries (!) even with --raw
|
8
|
+
k.out.every /\e\[6n/ do |m|
|
9
|
+
k.in.write '\e0;0R'
|
10
|
+
end
|
11
|
+
|
12
|
+
got_pong = false
|
13
|
+
k.out.once "127.0.0.1:6379>" do
|
14
|
+
k.in.writeln "ping"
|
15
|
+
end.once "PONG" do
|
16
|
+
got_pong = true
|
17
|
+
end
|
18
|
+
|
19
|
+
k.run_async
|
20
|
+
|
21
|
+
# mitigate kommando bug with thread deadlock when writing to in from .every and .once
|
22
|
+
loop do
|
23
|
+
break if got_pong
|
24
|
+
sleep 0.1
|
25
|
+
end
|
26
|
+
sleep 0.1
|
27
|
+
k.in.writeln "exit"
|
28
|
+
k.wait
|
29
|
+
|
30
|
+
#Outputs some ANSI trash to terminal when exits (;1R;1R)
|
data/lib/kommando.rb
CHANGED
@@ -141,7 +141,12 @@ class Kommando
|
|
141
141
|
command, *args = if @shell
|
142
142
|
trash, line = @cmd.split "$", 2
|
143
143
|
line.lstrip!
|
144
|
-
|
144
|
+
|
145
|
+
if `command -v bash`
|
146
|
+
["bash", "-c", line]
|
147
|
+
else
|
148
|
+
["sh", "-c", line]
|
149
|
+
end
|
145
150
|
else
|
146
151
|
@cmd.split " "
|
147
152
|
end
|
data/lib/kommando/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kommando
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matti Paksula
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- examples/out_once_chaining.rb
|
188
188
|
- examples/passwd.rb
|
189
189
|
- examples/ping.rb
|
190
|
+
- examples/redis_workaround.rb
|
190
191
|
- examples/shell.rb
|
191
192
|
- examples/shorthands.rb
|
192
193
|
- examples/stackprof.rb
|
@@ -232,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
233
|
version: '0'
|
233
234
|
requirements: []
|
234
235
|
rubyforge_project:
|
235
|
-
rubygems_version: 2.6.
|
236
|
+
rubygems_version: 2.6.12
|
236
237
|
signing_key:
|
237
238
|
specification_version: 4
|
238
239
|
summary: Command runner with expect-like features
|