eivo-rails 0.1.5 → 0.1.10
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/config/initializers/logger.rb +35 -0
- data/eivo-rails.gemspec +2 -1
- data/lib/eivo-rails.rb +1 -0
- data/lib/eivo-rails/environments/production.rb +9 -2
- data/lib/eivo-rails/formatter.rb +31 -0
- data/lib/generators/eivo/templates/config/puma.rb +4 -4
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35ce5c80a004d577ea1298d4fb342a4669eb666434f565d05c14a23448d1e3f1
|
4
|
+
data.tar.gz: 3d2a1c1d78622de67434d34cb255756e73defbb353e4e73a5c6b18083a958b8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f83055dc76c1e7c943896d6a8004feeefdfd0cc2e27512521142a89d1517c9e0ce223ac54aca8e22b4f5a1634693b0f75f17b9d1c21c3a58ec43ad1e966f15e0
|
7
|
+
data.tar.gz: 639bba272ae7a3563f102d77d54745aa04698a8a1a1321f287e2f502eb0f4debaaf93ddb7e148c82d7b816fea552480ee30aab1d08b5d47a2f87e9b1a4445c70
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lograge'
|
4
|
+
|
5
|
+
if Rails.env.staging? || Rails.env.production?
|
6
|
+
Rails.application.configure do
|
7
|
+
config.colorize_logging = false
|
8
|
+
|
9
|
+
config.lograge.enabled = true
|
10
|
+
config.lograge.formatter = ::Lograge::Formatters::Raw.new
|
11
|
+
config.lograge.base_controller_class = [
|
12
|
+
'ActionController::API',
|
13
|
+
'ActionController::Base'
|
14
|
+
]
|
15
|
+
|
16
|
+
config.lograge.ignore_actions = ['EIVO::StatusController#index']
|
17
|
+
|
18
|
+
config.lograge.custom_options = ->(event) do
|
19
|
+
result = {
|
20
|
+
params: event.payload[:params].except('controller', 'action', 'format'),
|
21
|
+
request_id: event.payload[:request_id]
|
22
|
+
}
|
23
|
+
|
24
|
+
result[:user_id] = event.payload[:user_id] if event.payload[:user_id]
|
25
|
+
result[:organization_id] = event.payload[:organization_id] if event.payload[:organization_id]
|
26
|
+
|
27
|
+
# https://github.com/roidrage/lograge/pull/307
|
28
|
+
if event.respond_to?(:allocations)
|
29
|
+
result[:allocations] = event.allocations
|
30
|
+
end
|
31
|
+
|
32
|
+
result
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/eivo-rails.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.push File.expand_path('lib', __dir__)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'eivo-rails'
|
7
|
-
spec.version = '0.1.
|
7
|
+
spec.version = '0.1.10'
|
8
8
|
spec.authors = ['Jonathan VUKOVICH-TRIBOUHARET']
|
9
9
|
spec.email = ['jonathan@eivo.co']
|
10
10
|
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_dependency 'oj'
|
26
26
|
|
27
27
|
spec.add_dependency 'sentry-raven'
|
28
|
+
spec.add_dependency 'lograge'
|
28
29
|
|
29
30
|
spec.add_development_dependency 'bundler'
|
30
31
|
spec.add_development_dependency 'rake'
|
data/lib/eivo-rails.rb
CHANGED
@@ -42,6 +42,7 @@ module EIVO
|
|
42
42
|
|
43
43
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
44
44
|
config.force_ssl = true
|
45
|
+
config.ssl_options = { redirect: { exclude: -> request { request.path == '/status' } } }
|
45
46
|
|
46
47
|
# Use the lowest log level to ensure availability of diagnostic information
|
47
48
|
# when problems arise.
|
@@ -72,9 +73,15 @@ module EIVO
|
|
72
73
|
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
73
74
|
|
74
75
|
if ENV['RAILS_LOG_TO_STDOUT'].present?
|
75
|
-
logger = ActiveSupport::Logger.new(STDOUT)
|
76
|
+
# logger = ActiveSupport::Logger.new(STDOUT)
|
77
|
+
# logger.formatter = config.log_formatter
|
78
|
+
# config.logger = ActiveSupport::TaggedLogging.new(logger)
|
79
|
+
|
80
|
+
config.log_formatter = ::EIVO::Formatter.new
|
81
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
76
82
|
logger.formatter = config.log_formatter
|
77
|
-
config.
|
83
|
+
config.log_level = :info
|
84
|
+
config.logger = logger
|
78
85
|
end
|
79
86
|
|
80
87
|
# Do not dump schema after migrations.
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
require 'multi_json'
|
5
|
+
|
6
|
+
module EIVO
|
7
|
+
class Formatter < ::Logger::Formatter
|
8
|
+
def call(severity, timestamp, progname, message)
|
9
|
+
json = {
|
10
|
+
pid: $PROCESS_ID,
|
11
|
+
level: severity,
|
12
|
+
timestamp: timestamp.utc.iso8601(3),
|
13
|
+
message: message
|
14
|
+
}
|
15
|
+
|
16
|
+
if progname
|
17
|
+
json[:tag] = progname
|
18
|
+
end
|
19
|
+
|
20
|
+
if defined?(::Sidekiq)
|
21
|
+
context = ::Sidekiq::Context.current
|
22
|
+
|
23
|
+
if !context.empty?
|
24
|
+
json[:context] = context
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
MultiJson.dump(json) << "\n"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
workers ENV.fetch('WEB_CONCURRENCY') { 0 }
|
4
|
-
threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
|
3
|
+
workers ENV.fetch('WEB_CONCURRENCY') { 0 }.to_i
|
4
|
+
threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i
|
5
5
|
threads threads_count, threads_count
|
6
6
|
|
7
7
|
environment ENV.fetch('RAILS_ENV') { 'development' }
|
@@ -9,7 +9,7 @@ environment ENV.fetch('RAILS_ENV') { 'development' }
|
|
9
9
|
if %w[production staging].include?(ENV['RAILS_ENV'])
|
10
10
|
pidfile 'tmp/pids/puma.pid'
|
11
11
|
state_path 'tmp/pids/puma.state'
|
12
|
-
daemonize
|
12
|
+
daemonize ActiveModel::Type::Boolean.new.cast(ENV.fetch('RAILS_DAEMONIZE') { false })
|
13
13
|
|
14
14
|
if ENV['PORT']
|
15
15
|
bind "tcp://0.0.0.0:#{ENV['PORT']}"
|
@@ -17,7 +17,7 @@ if %w[production staging].include?(ENV['RAILS_ENV'])
|
|
17
17
|
bind 'unix://tmp/sockets/puma.sock'
|
18
18
|
end
|
19
19
|
else
|
20
|
-
port ENV.fetch('PORT') { 3000 }
|
20
|
+
port ENV.fetch('PORT') { 3000 }.to_i
|
21
21
|
end
|
22
22
|
|
23
23
|
before_fork do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eivo-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan VUKOVICH-TRIBOUHARET
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: lograge
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: bundler
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,6 +156,7 @@ files:
|
|
142
156
|
- app/controllers/eivo/concerns/resources.rb
|
143
157
|
- app/controllers/eivo/status_controller.rb
|
144
158
|
- bin/eivo
|
159
|
+
- config/initializers/logger.rb
|
145
160
|
- config/initializers/sentry.rb
|
146
161
|
- config/routes.rb
|
147
162
|
- eivo-rails.gemspec
|
@@ -152,6 +167,7 @@ files:
|
|
152
167
|
- lib/eivo-rails/environments/production.rb
|
153
168
|
- lib/eivo-rails/environments/staging.rb
|
154
169
|
- lib/eivo-rails/environments/test.rb
|
170
|
+
- lib/eivo-rails/formatter.rb
|
155
171
|
- lib/generators/eivo/USAGE
|
156
172
|
- lib/generators/eivo/install_generator.rb
|
157
173
|
- lib/generators/eivo/templates/.env.example
|
@@ -187,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
203
|
- !ruby/object:Gem::Version
|
188
204
|
version: '0'
|
189
205
|
requirements: []
|
190
|
-
rubygems_version: 3.
|
206
|
+
rubygems_version: 3.1.2
|
191
207
|
signing_key:
|
192
208
|
specification_version: 4
|
193
209
|
summary: EIVO Rails
|