web47core 0.6.1 → 0.6.2
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/app/controllers/status_controller.rb +21 -68
- data/app/helpers/core_helper.rb +4 -0
- data/app/views/status/index.html.haml +1 -1
- data/lib/app/controllers/concerns/restful_controller.rb +6 -2
- data/lib/app/models/concerns/core_system_configuration.rb +1 -0
- data/lib/app/models/concerns/email_able.rb +6 -1
- data/lib/web47core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4fa89fdcd38c923f6fde1827baa6d3237f43120e9e82c25f9c13cc7817e580a
|
4
|
+
data.tar.gz: d25bd53993294c31e1a6f89ce6cffe76c38bd0058411c97c2f4027418a37be43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b9b6f4ed7fef7b154e7622f664c2c93bfbd6e26524523befd9b764d3d1f72525b06243b91e8c3fac057230dfff5f659017db4893b123665353e994c3cee2dad
|
7
|
+
data.tar.gz: ca8ecfac41f5bd5df4d766d48ad6823550d7fbbb62413c3820011edb151e59d5557edd18f4e967507a539fcd2731bd8198e5b352f3f6c546d95d376d034316e9
|
@@ -4,62 +4,36 @@
|
|
4
4
|
# Return the status of the server
|
5
5
|
#
|
6
6
|
class StatusController < ActionController::Base
|
7
|
-
protect_from_forgery with: :exception
|
8
7
|
#
|
9
8
|
# Main (and only) page
|
10
9
|
#
|
11
10
|
def index
|
12
|
-
components = { mongo: mongo_status,
|
13
|
-
redis: redis_status,
|
14
|
-
jobs: delayed_jobs_status,
|
15
|
-
cron_job_servers: cron_job_servers_status,
|
16
|
-
workers: workers_status }
|
11
|
+
components = { mongo: mongo_status, redis: redis_status, job_count: job_count_status, cron_job: cron_job_status }
|
17
12
|
|
18
13
|
respond_to do |format|
|
19
|
-
format.html { render :index, locals: { components:
|
14
|
+
format.html { render :index, locals: { components: components }, layout: false }
|
20
15
|
format.json { render json: components.to_json }
|
21
|
-
format.text
|
16
|
+
format.text do
|
17
|
+
overall = components.collect { |_key, item| item[:success] }.all?
|
18
|
+
render plain: components.flatten, status: overall ? 200 : 500
|
19
|
+
end
|
22
20
|
end
|
23
21
|
end
|
24
22
|
|
25
23
|
private
|
26
24
|
|
27
|
-
#
|
28
|
-
# Return the status of the key components, mongo, redis
|
29
|
-
#
|
30
|
-
def text_status(components)
|
31
|
-
components[:mongo][:success] && components[:redis][:success] ? 200 : 500
|
32
|
-
rescue StandardError
|
33
|
-
500
|
34
|
-
end
|
35
|
-
|
36
|
-
#
|
37
|
-
# Add UI decorators for HTML formatting
|
38
|
-
#
|
39
|
-
def ui_decorators(components)
|
40
|
-
components.each do |key, values|
|
41
|
-
if values[:success]
|
42
|
-
components[key][:icon_name] = 'check_circle'
|
43
|
-
components[key][:icon_color] = 'green-text'
|
44
|
-
else
|
45
|
-
components[key][:icon_name] = 'error'
|
46
|
-
components[key][:icon_color] = 'red-text'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
25
|
#
|
52
26
|
# Report an error for the check
|
53
27
|
#
|
54
|
-
def report_error(error
|
55
|
-
|
28
|
+
def report_error(error)
|
29
|
+
{ success: false, icon_name: 'error', icon_color: 'red-text', message: error.message }
|
56
30
|
end
|
57
31
|
|
58
32
|
#
|
59
33
|
# Report a success for the check
|
60
34
|
#
|
61
|
-
def report_success(message
|
62
|
-
|
35
|
+
def report_success(message)
|
36
|
+
{ success: true, icon_name: 'check_circle', icon_color: 'green-text', message: message }
|
63
37
|
end
|
64
38
|
|
65
39
|
#
|
@@ -68,9 +42,9 @@ class StatusController < ActionController::Base
|
|
68
42
|
def mongo_status
|
69
43
|
raise 'Mongo not available' if SystemConfiguration.count.zero?
|
70
44
|
|
71
|
-
report_success "#{SystemConfiguration.count} Configs"
|
45
|
+
report_success "#{SystemConfiguration.count} Configs"
|
72
46
|
rescue StandardError => error
|
73
|
-
report_error
|
47
|
+
report_error(error)
|
74
48
|
end
|
75
49
|
|
76
50
|
#
|
@@ -81,53 +55,32 @@ class StatusController < ActionController::Base
|
|
81
55
|
Rails.cache.write 'redis-status-check', value
|
82
56
|
raise 'Redis not available' unless value.eql?(Rails.cache.fetch('redis-status-check'))
|
83
57
|
|
84
|
-
report_success 'Redis Available'
|
58
|
+
report_success 'Redis Available'
|
85
59
|
rescue StandardError => error
|
86
|
-
report_error(error
|
60
|
+
report_error(error)
|
87
61
|
end
|
88
62
|
|
89
63
|
#
|
90
64
|
# Job Count
|
91
65
|
#
|
92
|
-
def
|
93
|
-
|
94
|
-
report_success "#{count} Jobs", count: count
|
66
|
+
def job_count_status
|
67
|
+
report_success "#{Delayed::Backend::Mongoid::Job.count} Jobs"
|
95
68
|
rescue StandardError => error
|
96
69
|
report_error(error)
|
97
70
|
end
|
98
71
|
|
99
72
|
#
|
100
|
-
# Cron job
|
73
|
+
# Cron job status
|
101
74
|
#
|
102
|
-
def
|
103
|
-
server =
|
75
|
+
def cron_job_status
|
76
|
+
server = Cron::Server.primary_server
|
104
77
|
raise 'No primary server' if server.blank?
|
105
78
|
|
106
79
|
server_info = "#{server.host_name}(#{server.pid}), last check in #{server.last_check_in_at}"
|
107
80
|
raise "Primary Server is DEAD: #{server_info}" if server.dead?
|
108
81
|
|
109
|
-
report_success "Primary Server is alive: #{server_info}"
|
110
|
-
primary_count: 1,
|
111
|
-
total_count: Cron::Server.count
|
82
|
+
report_success "Primary Server is alive: #{server_info}"
|
112
83
|
rescue StandardError => error
|
113
|
-
report_error(error
|
114
|
-
end
|
115
|
-
|
116
|
-
#
|
117
|
-
# Desired and current worker status for servers
|
118
|
-
#
|
119
|
-
def workers_status
|
120
|
-
server = cron_job_server
|
121
|
-
raise 'No primary server' if server.blank? || server.dead?
|
122
|
-
|
123
|
-
report_success "Workers #{server.desired_server_count}/ #{server.current_server_count}",
|
124
|
-
desired_count: server.desired_server_count,
|
125
|
-
current_count: server.current_server_count
|
126
|
-
rescue StandardError => error
|
127
|
-
report_error(error, desired_count: 0, current_count: 0)
|
128
|
-
end
|
129
|
-
|
130
|
-
def cron_job_server
|
131
|
-
@cron_job_server ||= Cron::Server.primary_server
|
84
|
+
report_error(error)
|
132
85
|
end
|
133
86
|
end
|
data/app/helpers/core_helper.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
%meta{ name: 'apple-mobile-web-app-status-bar-style', content: 'black'}
|
8
8
|
= stylesheet_link_tag 'https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css'
|
9
9
|
= stylesheet_link_tag 'https://fonts.googleapis.com/icon?family=Material+Icons'
|
10
|
-
%title
|
10
|
+
%title "#{Rails.env} Status"
|
11
11
|
%body{ style: 'background-color: #006064;'}
|
12
12
|
%header
|
13
13
|
%main
|
@@ -6,7 +6,7 @@
|
|
6
6
|
module RestfulController
|
7
7
|
#
|
8
8
|
# Render a JSON response with the results and status passed in. The payload will include
|
9
|
-
# an
|
9
|
+
# an SHA1 hash along with the response for validation.
|
10
10
|
#
|
11
11
|
def render_json_response(success = true, results = {}, status_code = :ok)
|
12
12
|
results[:success] = success
|
@@ -29,6 +29,10 @@ module RestfulController
|
|
29
29
|
# Create a hash of the string contents
|
30
30
|
#
|
31
31
|
def hash(str)
|
32
|
-
|
32
|
+
if SystemConfiguration.fips_mode?
|
33
|
+
Digest::SHA2.hexdigest(str)
|
34
|
+
else
|
35
|
+
Digest::MD5.hexdigest(str)
|
36
|
+
end
|
33
37
|
end
|
34
38
|
end
|
@@ -20,6 +20,7 @@ module CoreSystemConfiguration
|
|
20
20
|
# Fields
|
21
21
|
#
|
22
22
|
field :environment, type: String, default: 'test'
|
23
|
+
field :fips_mode, type: String, default: false
|
23
24
|
# SMTP configuration
|
24
25
|
field :default_email, type: String, default: 'support@app47.com'
|
25
26
|
field :support_email, type: String, default: 'support@app47.com'
|
@@ -76,7 +76,12 @@ module EmailAble
|
|
76
76
|
# Return the gravatar URL based on email address
|
77
77
|
#
|
78
78
|
def gravatar_url(size = '32', default = 'mm')
|
79
|
-
|
79
|
+
self.email ||= 'noone@abc.com'
|
80
|
+
if SystemConfiguration.fips_mode?
|
81
|
+
"https://www.gravatar.com/avatar/#{Digest::SHA2.hexdigest(email)}?s=#{size}&d=#{default}"
|
82
|
+
else
|
83
|
+
"https://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email)}?s=#{size}&d=#{default}"
|
84
|
+
end
|
80
85
|
end
|
81
86
|
|
82
87
|
private
|
data/lib/web47core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web47core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Schroeder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|