deis-interactive 0.0.3 → 0.0.4
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/bin/deis-rails +1 -2
- data/deis-interactive.gemspec +1 -0
- data/lib/deis-interactive/rails/logs.rb +49 -2
- data/lib/deis-interactive/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5f83196b1200c69ff190f99918194896970ef25
|
4
|
+
data.tar.gz: c94a10bb6aec193ad8c570875910a37b67081044
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1700bd2ce706c77a0d350950ffb3bbf7733cb6b45ce5054400a2ad841405b2bec8be19c1ce9ac55e19d645f811dbe4b96b961af5502443acf6fd4f6486071b3b
|
7
|
+
data.tar.gz: 4a93b6c21f8ebeb4011ac7210e0289e0dc57eef782b3e89799e611e7a75e912d7e59897887ba67e506286c8885337bf93ecdada21663a65f863c38aeb3eadfc3
|
data/bin/deis-rails
CHANGED
@@ -11,7 +11,7 @@ class DeisRails < Thor
|
|
11
11
|
DeisInteractive::Rails::Console.new(app).perform
|
12
12
|
end
|
13
13
|
|
14
|
-
desc "exec -a APP COMMAND PARAMS", "run
|
14
|
+
desc "exec -a APP COMMAND PARAMS", "run any command on an app"
|
15
15
|
method_option :app, aliases: ["a"], type: :string, required: true, desc: "Name of the app"
|
16
16
|
def exec(command, *params)
|
17
17
|
require_relative "../lib/deis-interactive/rails/exec"
|
@@ -21,7 +21,6 @@ class DeisRails < Thor
|
|
21
21
|
DeisInteractive::Rails::Exec.new(app, command, params).perform
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
24
|
desc "logs [-f] -a APP [-d PROCESS]", "logs on an app"
|
26
25
|
method_option :app, aliases: ["a"], type: :string, required: true, desc: "Name of the app"
|
27
26
|
method_option :process, aliases: ["p"], type: :string, required: false, desc: "Processes to be logged on"
|
data/deis-interactive.gemspec
CHANGED
@@ -1,14 +1,26 @@
|
|
1
1
|
require_relative 'base'
|
2
2
|
require "shellwords"
|
3
|
+
require 'concurrent'
|
4
|
+
require 'open3'
|
3
5
|
|
4
6
|
module DeisInteractive
|
5
7
|
module Rails
|
6
8
|
class Logs < Base
|
7
9
|
attr_reader :follow
|
10
|
+
attr_reader :pids
|
11
|
+
attr_reader :outputs
|
8
12
|
|
9
13
|
def initialize(app, process, follow: false)
|
10
14
|
super(app, process)
|
11
15
|
@follow = follow
|
16
|
+
@pids = Concurrent::Array.new
|
17
|
+
@outputs = Concurrent::Array.new
|
18
|
+
|
19
|
+
at_exit do
|
20
|
+
pids.each do |pid|
|
21
|
+
Process.kill("KILL", pid) if pid_alive?(pid)
|
22
|
+
end
|
23
|
+
end
|
12
24
|
end
|
13
25
|
|
14
26
|
def perform
|
@@ -21,6 +33,25 @@ module DeisInteractive
|
|
21
33
|
log_pods
|
22
34
|
end
|
23
35
|
|
36
|
+
def pid_alive?(pid)
|
37
|
+
begin
|
38
|
+
Process.getpgid( pid )
|
39
|
+
true
|
40
|
+
rescue Errno::ESRCH
|
41
|
+
false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def any_pid_alive?
|
46
|
+
20.times {
|
47
|
+
break if pids.count > 0
|
48
|
+
sleep 0.1
|
49
|
+
}
|
50
|
+
|
51
|
+
return false if pids.count == 0
|
52
|
+
pids.any? { |pid| pid_alive?(pid) }
|
53
|
+
end
|
54
|
+
|
24
55
|
def kube_options
|
25
56
|
if follow
|
26
57
|
"-f"
|
@@ -31,11 +62,27 @@ module DeisInteractive
|
|
31
62
|
pod_ids.each do |pod_id|
|
32
63
|
log_pod(pod_id)
|
33
64
|
end
|
65
|
+
|
66
|
+
loop do
|
67
|
+
while (outputs.count > 0)
|
68
|
+
puts outputs.shift
|
69
|
+
end
|
70
|
+
if any_pid_alive?
|
71
|
+
sleep 0.01
|
72
|
+
else
|
73
|
+
break
|
74
|
+
end
|
75
|
+
end
|
34
76
|
end
|
35
77
|
|
36
78
|
def log_pod(pod_id)
|
37
|
-
|
38
|
-
|
79
|
+
Thread.new do
|
80
|
+
cmd = "kubectl logs #{kube_options} #{pod_id} --namespace #{app}"
|
81
|
+
Open3.popen2e(cmd) do |_, out_err, wait_thr|
|
82
|
+
puts "Tracking #{wait_thr.pid}"
|
83
|
+
pids << wait_thr.pid
|
84
|
+
out_err.each { |line| outputs << line }
|
85
|
+
end
|
39
86
|
end
|
40
87
|
end
|
41
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deis-interactive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phuong Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: concurrent-ruby
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Wrapper for kubectl to quickly launch console to a deis app
|
42
56
|
email:
|
43
57
|
- phuongnd08@gmail.com
|