hephaestus 0.7.1 → 0.7.2.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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/app/controllers/concerns/hephaestus/responses.rb +107 -0
  4. data/app/controllers/concerns/hephaestus/validates_from_yetto.rb +51 -0
  5. data/app/controllers/hephaestus/application_controller.rb +42 -0
  6. data/app/controllers/hephaestus/root_controller.rb +10 -0
  7. data/app/controllers/hephaestus/settings_controller.rb +20 -0
  8. data/app/controllers/hephaestus/staff_controller.rb +20 -0
  9. data/app/jobs/hephaestus/application_job.rb +12 -0
  10. data/app/jobs/hephaestus/update_yetto_job.rb +39 -0
  11. data/app/models/hephaestus/application_record.rb +8 -0
  12. data/app/serializers/hephaestus/error_serializer.rb +18 -0
  13. data/app/serializers/hephaestus/headers.rb +27 -0
  14. data/app/services/hephaestus/yetto_service.rb +99 -0
  15. data/app/views/layouts/staff.html.erb +7 -0
  16. data/app/views/staff/index.html.erb +1 -0
  17. data/config/database.yml +49 -0
  18. data/config/environments/development.rb +89 -0
  19. data/config/environments/production.rb +96 -0
  20. data/config/environments/staging.rb +94 -0
  21. data/config/environments/test.rb +73 -0
  22. data/config/initializers/application.rb +14 -0
  23. data/config/initializers/cors.rb +19 -0
  24. data/config/initializers/environment.rb +94 -0
  25. data/config/initializers/filter_parameter_logging.rb +23 -0
  26. data/config/initializers/inflections.rb +21 -0
  27. data/config/initializers/litestream.rb +36 -0
  28. data/config/initializers/lograge.rb +27 -0
  29. data/config/initializers/opentelemetry.rb +41 -0
  30. data/config/initializers/sidekiq.rb +13 -0
  31. data/config/initializers/slack_webhook_logger.rb +19 -0
  32. data/config/litestream.yml +12 -0
  33. data/config/queue.yml +18 -0
  34. data/config/recurring.yml +10 -0
  35. data/config/routes.rb +17 -0
  36. data/db/queue_schema.rb +129 -0
  37. data/lib/hephaestus/support/hephaestus/webmocks/yetto_webmock.rb +1 -1
  38. data/lib/hephaestus/version.rb +1 -1
  39. data/templates/app/services/yetto_service.rb +1 -1
  40. metadata +36 -19
  41. data/templates/.dockerignore +0 -39
  42. data/templates/.env.sample +0 -6
  43. data/templates/.github/dependabot.yml +0 -27
  44. data/templates/.github/workflows/automerge.yml +0 -17
  45. data/templates/.github/workflows/deploy.yml +0 -30
  46. data/templates/.github/workflows/licenses.yml +0 -23
  47. data/templates/.github/workflows/lint.yml +0 -32
  48. data/templates/.github/workflows/security.yml +0 -15
  49. data/templates/.github/workflows/sorbet.yml +0 -19
  50. data/templates/.github/workflows/test.yml +0 -21
  51. data/templates/.licensed.yml +0 -43
  52. data/templates/.rubocop.yml +0 -5
  53. data/templates/.ruby-version +0 -1
  54. data/templates/.vscode/extensions.json +0 -9
  55. data/templates/.vscode/launch.json +0 -13
  56. data/templates/.vscode/settings.json +0 -52
  57. data/templates/test/integration/.keep +0 -0
  58. data/templates/test/mailers/.keep +0 -0
@@ -0,0 +1,96 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ require "active_support/core_ext/integer/time"
5
+
6
+ Rails.application.configure do
7
+ # Settings specified here will take precedence over those in config/application.rb.
8
+
9
+ # Code is not reloaded between requests.
10
+ config.enable_reloading = false
11
+
12
+ # Eager load code on boot. This eager loads most of Rails and
13
+ # your application in memory, allowing both threaded web servers
14
+ # and those relying on copy on write to perform better.
15
+ # Rake tasks automatically ignore this option for performance.
16
+ config.eager_load = true
17
+
18
+ # Full error reports are disabled and caching is turned on.
19
+ config.consider_all_requests_local = false
20
+ config.action_controller.perform_caching = true
21
+
22
+ # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
23
+ # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
24
+ # config.require_master_key = true
25
+
26
+ # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
27
+ # config.public_file_server.enabled = false
28
+
29
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
30
+ # config.asset_host = "http://assets.example.com"
31
+
32
+ # Specifies the header that your server uses for sending files.
33
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
34
+ # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
35
+
36
+ # Assume all access to the app is happening through a SSL-terminating reverse proxy.
37
+ # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
38
+ config.assume_ssl = true
39
+
40
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
41
+ config.force_ssl = true
42
+
43
+ # Skip http-to-https redirect for the default health check endpoint.
44
+ config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } }, hsts: { subdomains: true, preload: true, expires: 1.year } }
45
+
46
+ # Log to STDOUT by default
47
+ config.logger = ActiveSupport::Logger.new($stdout)
48
+ .tap { |logger| logger.formatter = Logger::Formatter.new }
49
+ .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
50
+
51
+ # Prepend all log lines with the following tags.
52
+ config.log_tags = [:request_id]
53
+
54
+ # "info" includes generic and useful information about system operation, but avoids logging too much
55
+ # information to avoid inadvertent exposure of personally identifiable information (PII). If you
56
+ # want to log everything, set the level to "debug".
57
+ config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
58
+
59
+ # Use a different cache store in production.
60
+ # config.cache_store = :mem_cache_store
61
+
62
+ # Use a real queuing backend for Active Job (and separate queues per environment).
63
+ config.active_job.queue_adapter = :solid_queue
64
+ config.solid_queue.connects_to = { database: { writing: :queue } }
65
+
66
+ # config.active_job.queue_name_prefix = "plug_email_production"
67
+
68
+ if defined?(ActionMailer)
69
+ # Disable caching for Action Mailer templates even if Action Controller
70
+ # caching is enabled.
71
+ config.action_mailer.perform_caching = false
72
+ end
73
+
74
+ # Ignore bad email addresses and do not raise email delivery errors.
75
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
76
+ # config.action_mailer.raise_delivery_errors = false
77
+
78
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
79
+ # the I18n.default_locale when a translation cannot be found).
80
+ config.i18n.fallbacks = true
81
+
82
+ # Don't log any deprecations.
83
+ config.active_support.report_deprecations = false
84
+
85
+ # Enable DNS rebinding protection and other `Host` header attacks.
86
+ # config.hosts = [
87
+ # "example.com", # Allow requests from example.com
88
+ # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
89
+ # ]
90
+ # Skip DNS rebinding protection for the default health check endpoint.
91
+ config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
92
+
93
+ config.after_initialize do
94
+ Rails.logger.broadcast_to(SlackWebhookLogger.logger)
95
+ end
96
+ end
@@ -0,0 +1,94 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ require "active_support/core_ext/integer/time"
5
+
6
+ Rails.application.configure do
7
+ # Settings specified here will take precedence over those in config/application.rb.
8
+
9
+ # Code is not reloaded between requests.
10
+ config.enable_reloading = false
11
+
12
+ # Eager load code on boot. This eager loads most of Rails and
13
+ # your application in memory, allowing both threaded web servers
14
+ # and those relying on copy on write to perform better.
15
+ # Rake tasks automatically ignore this option for performance.
16
+ config.eager_load = true
17
+
18
+ # Full error reports are disabled and caching is turned on.
19
+ config.consider_all_requests_local = false
20
+ config.action_controller.perform_caching = true
21
+
22
+ # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
23
+ # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
24
+ # config.require_master_key = true
25
+
26
+ # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
27
+ # config.public_file_server.enabled = false
28
+
29
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
30
+ # config.asset_host = "http://assets.example.com"
31
+
32
+ # Specifies the header that your server uses for sending files.
33
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
34
+ # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
35
+
36
+ # Assume all access to the app is happening through a SSL-terminating reverse proxy.
37
+ # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
38
+ config.assume_ssl = true
39
+
40
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
41
+ config.force_ssl = true
42
+
43
+ # Skip http-to-https redirect for the default health check endpoint.
44
+ config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } }, hsts: { subdomains: true, preload: true, expires: 1.year } }
45
+
46
+ # Log to STDOUT by default
47
+ config.logger = ActiveSupport::Logger.new($stdout)
48
+ .tap { |logger| logger.formatter = Logger::Formatter.new }
49
+ .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
50
+
51
+ # Prepend all log lines with the following tags.
52
+ config.log_tags = [:request_id]
53
+
54
+ # "info" includes generic and useful information about system operation, but avoids logging too much
55
+ # information to avoid inadvertent exposure of personally identifiable information (PII). If you
56
+ # want to log everything, set the level to "debug".
57
+ config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
58
+
59
+ # Use a different cache store in production.
60
+ # config.cache_store = :mem_cache_store
61
+
62
+ # Use a real queuing backend for Active Job (and separate queues per environment).
63
+ config.active_job.queue_adapter = :solid_queue
64
+ config.solid_queue.connects_to = { database: { writing: :queue } }
65
+
66
+ if defined?(ActionMailer)
67
+ # Disable caching for Action Mailer templates even if Action Controller
68
+ # caching is enabled.
69
+ config.action_mailer.perform_caching = false
70
+
71
+ # Ignore bad email addresses and do not raise email delivery errors.
72
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
73
+ # config.action_mailer.raise_delivery_errors = false
74
+ end
75
+
76
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
77
+ # the I18n.default_locale when a translation cannot be found).
78
+ config.i18n.fallbacks = true
79
+
80
+ # Don't log any deprecations.
81
+ config.active_support.report_deprecations = false
82
+
83
+ # Enable DNS rebinding protection and other `Host` header attacks.
84
+ # config.hosts = [
85
+ # "example.com", # Allow requests from example.com
86
+ # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
87
+ # ]
88
+ # Skip DNS rebinding protection for the default health check endpoint.
89
+ config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
90
+
91
+ config.after_initialize do
92
+ Rails.logger.broadcast_to(SlackWebhookLogger.logger)
93
+ end
94
+ end
@@ -0,0 +1,73 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ require "active_support/core_ext/integer/time"
5
+
6
+ # The test environment is used exclusively to run your application's
7
+ # test suite. You never need to work with it otherwise. Remember that
8
+ # your test database is "scratch space" for the test suite and is wiped
9
+ # and recreated between test runs. Don't rely on the data there!
10
+
11
+ Rails.application.configure do
12
+ # Settings specified here will take precedence over those in config/application.rb.
13
+
14
+ # While tests run files are not watched, reloading is not necessary.
15
+ config.enable_reloading = false
16
+
17
+ # Eager loading loads your entire application. When running a single test locally,
18
+ # this is usually not necessary, and can slow down your test suite. However, it's
19
+ # recommended that you enable it in continuous integration systems to ensure eager
20
+ # loading is working properly before deploying your code.
21
+ config.eager_load = ENV["CI"].present?
22
+
23
+ # Configure public file server for tests with Cache-Control for performance.
24
+ config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
25
+
26
+ # Show full error reports and disable caching.
27
+ config.consider_all_requests_local = true
28
+ config.action_controller.perform_caching = false
29
+ config.cache_store = :null_store
30
+
31
+ # Render exception templates for rescuable exceptions and raise for other exceptions.
32
+ config.action_dispatch.show_exceptions = :rescuable
33
+
34
+ # Disable request forgery protection in test environment.
35
+ config.action_controller.allow_forgery_protection = false
36
+
37
+ if defined?(ActionMailer)
38
+ # Disable caching for Action Mailer templates even if Action Controller
39
+ # caching is enabled.
40
+ config.action_mailer.perform_caching = false
41
+
42
+ # Tell Action Mailer not to deliver emails to the real world.
43
+ # The :test delivery method accumulates sent emails in the
44
+ # ActionMailer::Base.deliveries array.
45
+ config.action_mailer.delivery_method = :test
46
+
47
+ # Unlike controllers, the mailer instance doesn't have any context about the
48
+ # incoming request so you'll need to provide the :host parameter yourself.
49
+ config.action_mailer.default_url_options = { host: "www.example.com" }
50
+ end
51
+
52
+ # Print deprecation notices to the stderr.
53
+ config.active_support.deprecation = :stderr
54
+
55
+ # Raise exceptions for disallowed deprecations.
56
+ config.active_support.disallowed_deprecation = :raise
57
+
58
+ # Tell Active Support which deprecation messages to disallow.
59
+ config.active_support.disallowed_deprecation_warnings = []
60
+
61
+ # Raises error for missing translations.
62
+ # config.i18n.raise_on_missing_translations = true
63
+
64
+ # Annotate rendered view with file names.
65
+ # config.action_view.annotate_rendered_view_with_filenames = true
66
+
67
+ # Raise error when a before_action's only/except options reference missing actions.
68
+ config.action_controller.raise_on_missing_callback_actions = true
69
+
70
+ config.after_initialize do
71
+ Rails.logger.broadcast_to(SlackWebhookLogger.logger)
72
+ end
73
+ end
@@ -0,0 +1,14 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ Rails.application.configure do
5
+ # Configuration for the application, engines, and railties goes here.
6
+ #
7
+ # These settings can be overridden in specific environments using the files
8
+ # in config/environments, which are processed later.
9
+ #
10
+ config.time_zone = "UTC"
11
+
12
+ # Remove this in rails 8.1 as it will be the default
13
+ config.active_support.to_time_preserves_timezone = :zone
14
+ end
@@ -0,0 +1,19 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ # Be sure to restart your server when you modify this file.
5
+
6
+ # Avoid CORS issues when API is called from the frontend app.
7
+ # Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
8
+
9
+ # Read more: https://github.com/cyu/rack-cors
10
+
11
+ # Rails.application.config.middleware.insert_before 0, Rack::Cors do
12
+ # allow do
13
+ # origins "example.com"
14
+ #
15
+ # resource "*",
16
+ # headers: :any,
17
+ # methods: [:get, :post, :put, :patch, :delete, :options, :head]
18
+ # end
19
+ # end
@@ -0,0 +1,94 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ def set_env_var(production:, staging:, local:)
5
+ case Rails.env
6
+ when "production"
7
+ %x(op read "#{production}").chomp
8
+ when "staging"
9
+ %x(op read "#{staging}").chomp
10
+ else
11
+ local
12
+ end
13
+ end
14
+
15
+ def productionish?
16
+ Rails.env.production? || Rails.env.staging?
17
+ end
18
+
19
+ def print_user_api_errors?
20
+ (Rails.env.development? || Rails.env.staging?) || ENV.fetch("DEBUG", false)
21
+ end
22
+
23
+ def plug_shortname
24
+ plug_name.downcase
25
+ end
26
+
27
+ def plug_name
28
+ plug_module[4..] # 4= "Plug".length
29
+ end
30
+
31
+ def plug_module
32
+ Rails.application.class.module_parent.name
33
+ end
34
+
35
+ def plug_url
36
+ if Rails.env.production?
37
+ "#{plug_shortname}.plugs.yetto.app"
38
+ elsif Rails.env.staging?
39
+ "#{plug_shortname}.plugs.yetto.dev"
40
+ elsif Rails.env.development?
41
+ "#{%x(hostname).chomp.downcase}-plug-#{plug_shortname}.ngrok.io"
42
+ elsif Rails.env.test?
43
+ "#{plug_shortname}.plugs.yetto.test"
44
+ end
45
+ end
46
+
47
+ module Hephaestus
48
+ YETTO_EMAIL_DOMAIN = if Rails.env.production?
49
+ "yetto.email"
50
+ elsif Rails.env.staging?
51
+ "yetto.dev"
52
+ elsif Rails.env.development?
53
+ "yetto-dev.email"
54
+ elsif Rails.env.test?
55
+ "yetto.test"
56
+ end
57
+
58
+ PROTOCOL = Rails.env.development? ? "http://" : "https://"
59
+ YETTO_URL = if Rails.env.production?
60
+ "web.yetto.app"
61
+ elsif Rails.env.staging?
62
+ "web.yetto.dev"
63
+ elsif Rails.env.development?
64
+ "localhost:3000"
65
+ elsif Rails.env.test?
66
+ "web.yetto.test"
67
+ end
68
+
69
+ SLACK_LOG_URL = set_env_var(
70
+ production: "op://Infra/Secrets/SLACK_LOG_URL",
71
+ staging: "op://Infra/Secrets/SLACK_LOG_URL",
72
+ local: ENV.fetch("SLACK_LOG_URL", "https://slack.com/the_log_room"),
73
+ )
74
+
75
+ YETTO_API_URL = "#{YETTO_URL}/api"
76
+ YETTO_REDIRECT_URL = productionish? ? "#{PROTOCOL}#{YETTO_URL}" : "#{PROTOCOL}127.0.0.1:3000"
77
+
78
+ # Every plug has these secrets
79
+ YETTO_PLUG_PEM = set_env_var(
80
+ production: "op://Plug-#{plug_name}/Production/YETTO_PLUG_PEM",
81
+ staging: "op://Plug-#{plug_name}/Staging/YETTO_PLUG_PEM",
82
+ local: ENV.fetch("YETTO_PLUG_PEM", Rails.root.join("test/fixtures/files/fake_pem_file/fake.pem").read),
83
+ )
84
+ YETTO_SIGNING_SECRET = set_env_var(
85
+ production: "op://Plug-#{plug_name}/Production/YETTO_SIGNING_SECRET",
86
+ staging: "op://Plug-#{plug_name}/Staging/YETTO_SIGNING_SECRET",
87
+ local: ENV.fetch("YETTO_SIGNING_SECRET", "super-secret"),
88
+ )
89
+ YETTO_PLUG_ID = set_env_var(
90
+ production: "op://Plug-#{plug_name}/Production/YETTO_PLUG_ID",
91
+ staging: "op://Plug-#{plug_name}/Staging/YETTO_PLUG_ID",
92
+ local: ENV.fetch("YETTO_PLUG_ID", "plug-id"),
93
+ )
94
+ end
@@ -0,0 +1,23 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ # Be sure to restart your server when you modify this file.
5
+
6
+ # Configure parameters to be filtered from the log file. Use this to limit dissemination of
7
+ # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
8
+ # notations and behaviors.
9
+ Rails.application.config.filter_parameters += [
10
+ :passw,
11
+ :secret,
12
+ :token,
13
+ :_key,
14
+ :crypt,
15
+ :salt,
16
+ :certificate,
17
+ :otp,
18
+ :ssn,
19
+ :credentials,
20
+ :html_content,
21
+ :text_content,
22
+ :attachments,
23
+ ]
@@ -0,0 +1,21 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ # Be sure to restart your server when you modify this file.
5
+
6
+ # Add new inflection rules using the following format. Inflections
7
+ # are locale specific, and you may define rules for as many different
8
+ # locales as you wish. All of these examples are active by default:
9
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
10
+ # inflect.plural /^(ox)$/i, "\\1en"
11
+ # inflect.singular /^(ox)en/i, "\\1"
12
+ # inflect.irregular "person", "people"
13
+ # inflect.uncountable %w( fish sheep )
14
+ # end
15
+
16
+ # These inflection rules are supported but not enabled by default:
17
+ ActiveSupport::Inflector.inflections(:en) do |inflect|
18
+ inflect.acronym("API")
19
+ inflect.acronym("HTTP")
20
+ inflect.acronym("GitHub")
21
+ end
@@ -0,0 +1,36 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ # Use this hook to configure the litestream-ruby gem.
5
+ # All configuration options will be available as environment variables, e.g.
6
+ # config.replica_bucket becomes LITESTREAM_REPLICA_BUCKET
7
+ # This allows you to configure Litestream using Rails encrypted credentials,
8
+ # or some other mechanism where the values are only avaialble at runtime.
9
+
10
+ Rails.application.configure do
11
+ # An example of using Rails encrypted credentials to configure Litestream.
12
+ # litestream_credentials = Rails.application.credentials.litestream
13
+
14
+ # Replica-specific bucket location.
15
+ # This will be your bucket's URL without the `https://` prefix.
16
+ # For example, if you used DigitalOcean Spaces, your bucket URL could look like:
17
+ # https://myapp.fra1.digitaloceanspaces.com
18
+ # And so you should set your `replica_bucket` to:
19
+ # myapp.fra1.digitaloceanspaces.com
20
+ # Litestream supports Azure Blog Storage, Backblaze B2, DigitalOcean Spaces,
21
+ # Scaleway Object Storage, Google Cloud Storage, Linode Object Storage, and
22
+ # any SFTP server.
23
+ # In this example, we are using Rails encrypted credentials to store the URL to
24
+ # our storage provider bucket.
25
+ # config.litestream.replica_bucket = litestream_credentials&.replica_bucket
26
+
27
+ # Replica-specific authentication key.
28
+ # Litestream needs authentication credentials to access your storage provider bucket.
29
+ # In this example, we are using Rails encrypted credentials to store the access key ID.
30
+ # config.litestream.replica_key_id = litestream_credentials&.replica_key_id
31
+
32
+ # Replica-specific secret key.
33
+ # Litestream needs authentication credentials to access your storage provider bucket.
34
+ # In this example, we are using Rails encrypted credentials to store the secret access key.
35
+ # config.litestream.replica_access_key = litestream_credentials&.replica_access_key
36
+ end
@@ -0,0 +1,27 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ require "lograge"
5
+
6
+ Rails.application.configure do
7
+ config.lograge.enabled = true
8
+ config.lograge.custom_options = lambda do |event|
9
+ span = OpenTelemetry::Trace.current_span
10
+ {
11
+ time: event.time,
12
+ trace_id: span.context.hex_trace_id,
13
+ span_id: span.context.hex_span_id,
14
+ }
15
+ end
16
+
17
+ config.lograge.custom_payload do |controller|
18
+ payload = {
19
+ host: controller.request.host,
20
+ }
21
+
22
+ payload
23
+ end
24
+
25
+ config.lograge.keep_original_rails_log = true
26
+ config.lograge.logger = ActiveSupport::Logger.new(Rails.root.join("log", "lograge_#{Rails.env}.log"))
27
+ end
@@ -0,0 +1,41 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ unless Rails.env.development?
5
+ # establish the environment for OTEL
6
+ ENV["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://api.honeycomb.io"
7
+
8
+ ENV["OTEL_EXPORTER_OTLP_HEADERS"] = set_env_var(
9
+ production: "op://Plug-#{plug_name}/Production/OTEL_EXPORTER_OTLP_HEADERS",
10
+ staging: "op://Plug-#{plug_name}/Staging/OTEL_EXPORTER_OTLP_HEADERS",
11
+ local: ENV.fetch("OTEL_EXPORTER_OTLP_HEADERS", "x-honeycomb-team=your-api-key"),
12
+ )
13
+
14
+ ENV["OTEL_SERVICE_NAME"] = "plug-#{plug_shortname}-#{Rails.env}"
15
+
16
+ require "opentelemetry/sdk"
17
+ require "opentelemetry/semantic_conventions"
18
+
19
+ OpenTelemetry::SDK.configure do |c|
20
+ c.logger = Rails.logger
21
+
22
+ c.use_all(
23
+ "OpenTelemetry::Instrumentation::PG" => { db_statement: :obfuscate },
24
+ "OpenTelemetry::Instrumentation::Rack" => { use_rack_events: false },
25
+ )
26
+
27
+ if productionish?
28
+ c.add_span_processor(
29
+ OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
30
+ OpenTelemetry::Exporter::OTLP::Exporter.new,
31
+ ),
32
+ )
33
+ else # useful for testing instrumentation
34
+ c.add_span_processor(
35
+ OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(
36
+ OpenTelemetry::SDK::Trace::Export::SpanExporter.new,
37
+ ),
38
+ )
39
+ end # development is intentionally disabled
40
+ end
41
+ end
@@ -0,0 +1,13 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ require "sidekiq"
5
+
6
+ Sidekiq.configure_server do |config|
7
+ config.logger = Sidekiq::Logger.new($stdout)
8
+ config.redis = { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/1") }
9
+ end
10
+ Sidekiq.configure_client do |config|
11
+ config.logger = Sidekiq::Logger.new($stdout)
12
+ config.redis = { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/1") }
13
+ end
@@ -0,0 +1,19 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ require "slack_webhook_logger"
5
+
6
+ SlackWebhookLogger.setup do |config|
7
+ # Webhook URL
8
+ #
9
+ # The URL where messages will be sent.
10
+ config.webhook_url = Hephaestus::SLACK_LOG_URL
11
+
12
+ # The minimum error level to see in Slack.
13
+ #
14
+ # All log levels are supported, but don't do anything less then :warn since Slack only allows one message
15
+ # per minute.
16
+ config.level = :WARN
17
+
18
+ config.ignore_patterns = [/Can't verify CSRF token authenticity/, /is not a valid MIME type/]
19
+ end
@@ -0,0 +1,12 @@
1
+ # This is the actual configuration file for litestream.
2
+ #
3
+ # You can either use the generated `config/initializers/litestream.rb`
4
+ # file to configure the litestream-ruby gem, which will populate these
5
+ # ENV variables when using the `rails litestream:replicate` command.
6
+ #
7
+ # Or, if you prefer, manually manage ENV variables and this configuration file.
8
+ # In that case, simply ensure that the ENV variables are set before running the
9
+ # `replicate` command.
10
+ #
11
+ # For more details, see: https://litestream.io/reference/config/
12
+ dbs:
data/config/queue.yml ADDED
@@ -0,0 +1,18 @@
1
+ default: &default
2
+ dispatchers:
3
+ - polling_interval: 1
4
+ batch_size: 500
5
+ workers:
6
+ - queues: [high_priority*, mid_priority*, low_priority*]
7
+ threads: 5
8
+ - queues: "*" # default, mailers, etc
9
+ threads: 3
10
+
11
+ development:
12
+ <<: *default
13
+
14
+ test:
15
+ <<: *default
16
+
17
+ production:
18
+ <<: *default
@@ -0,0 +1,10 @@
1
+ # production:
2
+ # periodic_cleanup:
3
+ # class: CleanSoftDeletedRecordsJob
4
+ # queue: background
5
+ # args: [ 1000, { batch_size: 500 } ]
6
+ # schedule: every hour
7
+ # periodic_command:
8
+ # command: "SoftDeletedRecord.due.delete_all"
9
+ # priority: 2
10
+ # schedule: at 5am every day
data/config/routes.rb ADDED
@@ -0,0 +1,17 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ # this file doesn't actually do anything; consumed routes are
5
+ # in lib/hephaestus/engine.rb
6
+ Hephaestus::Engine.routes.draw do
7
+ resources :settings, only: [:new, :edit]
8
+
9
+ #############################################
10
+ # error pages -- these MUST be at the end! ##
11
+ #############################################
12
+
13
+ get "/500", to: "application#render500" if Rails.env.production? || Rails.env.staging?
14
+
15
+ match "/", to: "application#not_found", via: :all
16
+ match "/*unmatched_route", to: "application#not_found", via: :all
17
+ end