openstax_utilities 4.4.0 → 4.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/openstax/utilities/status_controller.rb +22 -6
- data/app/views/layouts/openstax/utilities/status.html.erb +3 -5
- data/app/views/openstax/utilities/status/index.html.erb +11 -4
- data/lib/openstax/utilities/engine.rb +5 -1
- data/lib/openstax/utilities/version.rb +1 -1
- data/lib/openstax_utilities.rb +2 -0
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a0f5f4c56fdba82e036469ad782df61b733f67e3061ea4c12416257d399e477
|
4
|
+
data.tar.gz: 063645a0e123dc5e916f499a4ce3ecfa734a04a2092742e9bb5c200be52a55c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f698f5074753000c1a83989a6aa78238d00fb17291390c8f0abef3eb7112be2fa4edb72a068bdfade5cab9f56df401a8027bfff79b1b0af521557b8795e2682f
|
7
|
+
data.tar.gz: c1aa9accccf3acad744e2090762f6c83af9c3e2cc0f0d8f2d0c30eb2b8277b40490740d741403c53a643b9666bfa24f0454a0a1b6a8a1d5dceef0e4ad7207f24
|
@@ -1,16 +1,19 @@
|
|
1
1
|
require 'aws-sdk-autoscaling'
|
2
2
|
|
3
3
|
class OpenStax::Utilities::StatusController < ActionController::Base
|
4
|
+
before_action :authenticate
|
5
|
+
|
4
6
|
layout 'openstax/utilities/status'
|
5
7
|
|
6
8
|
def index
|
7
|
-
@application_name =
|
9
|
+
@application_name = OSU::SITE_NAME.humanize
|
8
10
|
@environment_name = Rails.application.secrets.environment_name
|
9
11
|
|
10
12
|
@statuses = if @environment_name == 'development'
|
11
13
|
[ [ 'local', 1, 1, :ok ] ]
|
12
14
|
else
|
13
|
-
queues =
|
15
|
+
queues = Module.const_defined?(:Delayed) && Delayed.const_defined?(:Worker) ?
|
16
|
+
Delayed::Worker.queue_attributes.keys.map(&:to_s) - [ 'migration' ] : []
|
14
17
|
asgs = [ 'migration', 'web', 'cron', 'background' ] + queues.map do |queue|
|
15
18
|
"background-#{queue}"
|
16
19
|
end
|
@@ -25,17 +28,24 @@ class OpenStax::Utilities::StatusController < ActionController::Base
|
|
25
28
|
).chomp('-asg')
|
26
29
|
|
27
30
|
status = if asg.desired_capacity == 0
|
28
|
-
if
|
29
|
-
:shutting_down
|
30
|
-
elsif [ 'web', 'background', 'cron' ].include?(name)
|
31
|
+
if [ 'web', 'background', 'cron' ].include?(name)
|
31
32
|
:configuration_error
|
33
|
+
elsif asg.instances.size > 0
|
34
|
+
:shutting_down
|
32
35
|
else
|
33
36
|
:sleeping
|
34
37
|
end
|
35
38
|
elsif asg.instances.all? do |instance|
|
36
39
|
instance.health_status != 'Healthy' || instance.lifecycle_state != 'InService'
|
37
40
|
end
|
38
|
-
|
41
|
+
case name
|
42
|
+
when 'web'
|
43
|
+
:down
|
44
|
+
when 'background', 'cron'
|
45
|
+
:impacted
|
46
|
+
else
|
47
|
+
:offline
|
48
|
+
end
|
39
49
|
elsif name == 'migration'
|
40
50
|
:migrating
|
41
51
|
elsif asg.max_size > 1 && asg.desired_capacity == asg.max_size
|
@@ -63,4 +73,10 @@ class OpenStax::Utilities::StatusController < ActionController::Base
|
|
63
73
|
end
|
64
74
|
end
|
65
75
|
end
|
76
|
+
|
77
|
+
protected
|
78
|
+
|
79
|
+
def authenticate
|
80
|
+
instance_exec &OpenStax::Utilities.configuration.status_authenticate
|
81
|
+
end
|
66
82
|
end
|
@@ -13,12 +13,10 @@
|
|
13
13
|
</head>
|
14
14
|
|
15
15
|
<body id="status" class="status">
|
16
|
-
<
|
17
|
-
<
|
18
|
-
|
16
|
+
<div class="body">
|
17
|
+
<div class="body-container" style="margin-left: 16px;">
|
18
|
+
<header><h2><%= title %></h2></header>
|
19
19
|
|
20
|
-
<div class="body" style="margin-left: 16px;">
|
21
|
-
<div class="body-container">
|
22
20
|
<%= yield %>
|
23
21
|
</div>
|
24
22
|
</div>
|
@@ -1,13 +1,15 @@
|
|
1
1
|
<%
|
2
2
|
status_icons = {
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
configuration_error: '💀',
|
4
|
+
down: '💥',
|
5
|
+
impacted: '⚠️',
|
6
6
|
at_capacity: '🥵',
|
7
|
+
migrating: '💾',
|
7
8
|
scaling_down: '📉',
|
8
9
|
scaling_up: '📈',
|
9
|
-
migrating: '💾',
|
10
10
|
ok: '✅',
|
11
|
+
shutting_down: '😪',
|
12
|
+
offline: '🔌',
|
11
13
|
sleeping: '💤'
|
12
14
|
}
|
13
15
|
|
@@ -23,6 +25,11 @@
|
|
23
25
|
<li>
|
24
26
|
Frontend (tutor-js): <%= OpenStax::Utilities::Assets.manifest.version || 'not deployed' %>
|
25
27
|
</li>
|
28
|
+
<li>
|
29
|
+
Deployment (tutor-deployment): <%=
|
30
|
+
Rails.application.secrets.deployment_version || 'not deployed'
|
31
|
+
%>
|
32
|
+
</li>
|
26
33
|
</ul>
|
27
34
|
|
28
35
|
<% status = status_icons.find { |key, _| @statuses.any? { |_, _, _, status| status == key } } %>
|
@@ -11,7 +11,11 @@ module OpenStax
|
|
11
11
|
isolate_namespace OpenStax::Utilities
|
12
12
|
|
13
13
|
config.after_initialize do
|
14
|
-
|
14
|
+
if Rails::VERSION::MAJOR == 6
|
15
|
+
OSU::SITE_NAME = ::Rails.application.class.module_parent_name.underscore
|
16
|
+
else
|
17
|
+
OSU::SITE_NAME = ::Rails.application.class.parent_name.underscore
|
18
|
+
end
|
15
19
|
end
|
16
20
|
|
17
21
|
config.generators do |g|
|
data/lib/openstax_utilities.rb
CHANGED
@@ -57,11 +57,13 @@ module OpenStax
|
|
57
57
|
attr_accessor :standard_date_format
|
58
58
|
attr_accessor :standard_datetime_format
|
59
59
|
attr_accessor :standard_time_format
|
60
|
+
attr_accessor :status_authenticate
|
60
61
|
|
61
62
|
def initialize
|
62
63
|
@standard_date_format = "%b %d, %Y"
|
63
64
|
@standard_datetime_format = "%b %d, %Y %l:%M %p %Z"
|
64
65
|
@standard_time_format = "%l:%M %p %Z"
|
66
|
+
@status_authenticate = -> { head :forbidden }
|
65
67
|
super
|
66
68
|
end
|
67
69
|
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstax_utilities
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Slavinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
22
|
+
version: '7.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.0'
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
32
|
+
version: '7.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: lev
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -253,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
259
|
- !ruby/object:Gem::Version
|
254
260
|
version: '0'
|
255
261
|
requirements: []
|
256
|
-
rubygems_version: 3.
|
262
|
+
rubygems_version: 3.2.7
|
257
263
|
signing_key:
|
258
264
|
specification_version: 4
|
259
265
|
summary: Utilities for OpenStax web sites
|