opsicle 0.13.0 → 0.13.1
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/opsicle/monitor/app.rb +23 -13
- data/lib/opsicle/version.rb +1 -1
- data/spec/opsicle/commands/update_spec.rb +2 -1
- data/spec/opsicle/monitor/app_spec.rb +10 -0
- 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: 0baf2ced70ed7f2d668ef04fd18e666c3c1e0b52
|
4
|
+
data.tar.gz: 74431df218528ff5e3e3a75cc4106537149ca150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d88d1230288fb6adcb4c18a0a6d23742043bf8561955af051ada5fc33d35181633b8e714d3ab8d2bb5e1272f91cc0d96a572e71752564b6a6c2fa99e288980fc
|
7
|
+
data.tar.gz: 9054a81eb6a19777f1424c9f961604b464c9aa64d65d5cd888d090fa22174177269f29032a1a870d5461cde5b6629547225373b8f23770a054301eccd9846b36
|
data/lib/opsicle/monitor/app.rb
CHANGED
@@ -29,25 +29,33 @@ module Opsicle
|
|
29
29
|
|
30
30
|
# Make client with correct configuration available to monitor spies
|
31
31
|
App.client = Client.new(environment)
|
32
|
-
|
32
|
+
if @deployment_id
|
33
|
+
# `deploy`, `chef-update`, `execute-recipes` command, which is no-tty compatible so these can be automated via cron, etc.
|
34
|
+
@deploy = Opsicle::Deployment.new(@deployment_id, App.client)
|
35
|
+
else
|
36
|
+
# `monitor` command, which requires a TTY.
|
37
|
+
raise "Monitor requires a TTY." unless $stdout.tty?
|
38
|
+
end
|
33
39
|
end
|
34
40
|
|
35
41
|
def start
|
36
42
|
begin
|
37
43
|
@running = true
|
38
44
|
|
39
|
-
|
45
|
+
if $stdout.tty?
|
46
|
+
setup
|
40
47
|
|
41
|
-
|
42
|
-
|
43
|
-
|
48
|
+
@threads[:command] ||= Thread.new do
|
49
|
+
command_loop # listen for commands
|
50
|
+
end
|
44
51
|
|
45
|
-
|
46
|
-
|
47
|
-
|
52
|
+
@threads[:refresh_screen] ||= Thread.new do
|
53
|
+
refresh_screen_loop # refresh frequently
|
54
|
+
end
|
48
55
|
|
49
|
-
|
50
|
-
|
56
|
+
@threads[:refresh_data] ||= Thread.new do
|
57
|
+
refresh_data_loop # refresh not so frequently
|
58
|
+
end
|
51
59
|
end
|
52
60
|
|
53
61
|
if @deploy
|
@@ -67,7 +75,7 @@ module Opsicle
|
|
67
75
|
|
68
76
|
@running = false
|
69
77
|
wakey_wakey
|
70
|
-
@screen.close
|
78
|
+
@screen.close unless @screen.nil?
|
71
79
|
@screen = nil # Ruby curses lib doesn't have closed?(), so we set to nil, just in case
|
72
80
|
|
73
81
|
options[:error] ? raise(options[:error]) : raise(QuitMonitor, options[:message])
|
@@ -159,7 +167,7 @@ module Opsicle
|
|
159
167
|
# to the spies would get ugly.
|
160
168
|
def refresh_deploy_status_loop
|
161
169
|
while @running do
|
162
|
-
next unless @screen
|
170
|
+
next unless @screen || !$stdout.tty?# HACK: only certain test scenarios?
|
163
171
|
|
164
172
|
check_deploy_status
|
165
173
|
|
@@ -168,7 +176,9 @@ module Opsicle
|
|
168
176
|
end
|
169
177
|
|
170
178
|
def check_deploy_status
|
171
|
-
|
179
|
+
if deploy.running?
|
180
|
+
Output.say(". ") unless $stdout.tty?
|
181
|
+
else
|
172
182
|
if deploy.failed?
|
173
183
|
stop(error: Opsicle::Errors::DeployFailed.new(deploy.command))
|
174
184
|
elsif deploy.successful?
|
data/lib/opsicle/version.rb
CHANGED
@@ -49,7 +49,8 @@ module Opsicle
|
|
49
49
|
it "should print changes with table" do
|
50
50
|
allow(HashDiff).to receive(:diff) { [%w[- nyan 1], %w[+ cat 2],%w[~ taco 3 4]] }
|
51
51
|
expect(Output).to receive(:say).with("Changes: 3") { nil }
|
52
|
-
|
52
|
+
allow(Output).to receive_message_chain("terminal.say")
|
53
|
+
allow(Output).to receive_message_chain("terminal.color")
|
53
54
|
subject.print(nil, nil)
|
54
55
|
end
|
55
56
|
end
|
@@ -30,6 +30,11 @@ describe Opsicle::Monitor::App do
|
|
30
30
|
expect(@app.restarting).to equal(false)
|
31
31
|
end
|
32
32
|
|
33
|
+
it "raises error without a tty" do
|
34
|
+
expect($stdout).to receive(:tty?) { false }
|
35
|
+
expect { Opsicle::Monitor::App.new("staging", {}) }.to raise_error(RuntimeError, "Monitor requires a TTY.")
|
36
|
+
end
|
37
|
+
|
33
38
|
context "when the app is montoring a deploy" do
|
34
39
|
before do
|
35
40
|
@app = Opsicle::Monitor::App.new("staging", {:deployment_id => 123})
|
@@ -42,6 +47,11 @@ describe Opsicle::Monitor::App do
|
|
42
47
|
it "assigns a deploy" do
|
43
48
|
expect(@app.deploy).to be_an_instance_of(Opsicle::Deployment)
|
44
49
|
end
|
50
|
+
|
51
|
+
it "works without a tty for a deployment" do
|
52
|
+
allow($stdout).to receive(:tty?) { false }
|
53
|
+
Opsicle::Monitor::App.new("staging", {:deployment_id => 123})
|
54
|
+
end
|
45
55
|
end
|
46
56
|
|
47
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opsicle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Fleener
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|