From d0b98e56290172033a4f83679fc8d68425d3ee72 Mon Sep 17 00:00:00 2001 From: lorenzo farnararo Date: Fri, 23 Aug 2024 12:55:04 +0200 Subject: [PATCH] email 500 error to user removed, added remote logs, moved smtp pass to credentials, status page moved --- Gemfile | 2 ++ Gemfile.lock | 13 +++++++++++++ app/views/application/_footer.erb | 2 +- config/application.rb | 7 +++++++ config/credentials.yml.enc | 2 +- config/deploy.yml | 7 +++---- config/environments/production.rb | 4 ++-- config/initializers/devise.rb | 2 +- 8 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index 7d47cca..ada3c8a 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,8 @@ gem 'pg', '~> 1.5.7' gem 'puma', '>= 5.0' # Metrics +gem 'logtail-rails', '~> 0.2.7' + gem 'yabeda' gem 'yabeda-prometheus' gem 'yabeda-puma-plugin' diff --git a/Gemfile.lock b/Gemfile.lock index b919195..1531565 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -212,6 +212,17 @@ GEM rails language_server-protocol (3.17.0.3) logger (1.6.0) + logtail (0.1.13) + msgpack (~> 1.0) + logtail-rack (0.2.5) + logtail (~> 0.1) + rack (>= 1.2, < 4.0) + logtail-rails (0.2.7) + actionpack (>= 5.0.0) + activerecord (>= 5.0.0) + logtail (~> 0.1) + logtail-rack (~> 0.1) + railties (>= 5.0.0) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -231,6 +242,7 @@ GEM rails (>= 7.1) stimulus-rails turbo-rails + msgpack (1.7.2) net-imap (0.4.14) date net-protocol @@ -468,6 +480,7 @@ DEPENDENCIES kamal kaminari kaminari-i18n + logtail-rails (~> 0.2.7) mission_control-jobs (~> 0.3.1) pg (~> 1.5.7) puma (>= 5.0) diff --git a/app/views/application/_footer.erb b/app/views/application/_footer.erb index dbc3993..01b4d41 100644 --- a/app/views/application/_footer.erb +++ b/app/views/application/_footer.erb @@ -7,7 +7,7 @@ <% if ENV['APP_VERSION'].present? %> v<%= ENV['APP_VERSION'] %> <% end %> - + Status diff --git a/config/application.rb b/config/application.rb index f386d8f..5e24501 100644 --- a/config/application.rb +++ b/config/application.rb @@ -28,5 +28,12 @@ class Application < Rails::Application config.i18n.default_locale = :it config.hosts = [] + if Rails.env.production? + config.logger = Logtail::Logger.create_default_logger( + Rails.application.credentials.dig( + :vector, :rails_logs_token + ) + ) + end end end diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index 9efe969..d93baf7 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -7oy95ugAD40HGsmY8yhQEecWvJNpzytpCPMNSYHKO3X31Ykveauj4LEWMN9uhiJ6+1pJxahIO6iFiO7eP6AQBaBMcSfw0daPRfhJnm0X6+IekEw4Fl538W1hOntvw4fQkPqNP4eJMpTgTuH1LrMOFOOvgAVxlgouL9ybl7ZzFdYo8PfIjM7QjODTbHgPKU8orPgm/raFpIHcQFTd1EP1XUdXemnvzxJrGX7d1WWwrl4U70rM3N6HfH/G+OycFTlixGpKr+QiRtm4FpGtJSltQZDAGXk6jOZxjDHQA59WhHsz0lE68+cHRUqz7XUN6MkRAnZXRd1mYDI6LYQmRUgk3vJPtWkNpJnvGH8/Gn7wNuhTkWBlXnb0FUW3nkXKWi4iKIT4wsHOzJU7jA3HpxocRyKijRuWN6YPOGsyWdtgWGmiK7lEYV1A2Ug4LFHxjGmIrUXMYwNBJUvzJ2UCrKabqzs2ic8z5zrOZWqkazrZSwpZBPC3Zs9CQGEC861TJPW6S/xAkigmr9tYRGN3SZ4xYCVxMV91tMkzjco8qPOPJ9blNQ==--acgKvtBV5WCvw07y--cnaqYfJ0+foy95l8r2lIQQ== \ No newline at end of file +/K5V6jf8psjxWALA9phkzER3c/3aszNe6tfG8eCGSGFulMESSC6T3k6gQsGQvvQHzVv1u7KsNoGjd86ZW3shpWR5IaPPGF/HKqxhHgyZZF8dVrMRyOlhI/VaNCIWOIhXgq2uTZiw+4LWBaqKF+ecCpZxAdFZhBx8DMmXGfoPi2yXuF6zsL+zVnxsgsSTe1zhArFsSI119g1nGOa2DgKU1ScMh1o7viVtTOjtfb+zJ/g7RBHs3xXdOAR0Fy4g/JghwcwfeYbHH0PaWzN38bUFTijMpCAqoeD8+71iKIchTF8v6Q0Lg3X6cItOS57258WlvnpIzfW8N7mTZjiXz9MiqRTehW56aLzS1q5L+RqRIw3tNI0rc3NsDpLNIvT6l+SOFEwWhr/9tABWz+Z/+EcgPPl8PJZUwJuSar43kIHch0NEZIkq1ABa25t2W3qiOHJZJui5g0sGFhQA8F8cFfr+/hvjSvmMpnMQLnNZGeML7zpsKkaQZcAauaBqso1oltigY28ax7VCwd+a0lO2MiBXUde82LT4aOK0PavpSsaeM/KINIlfxL/+QL6AleyDYj5sFAKxtz9w1vXymGYwNZp8oC1BtVwQlelrsZq9Orlz/RhomF15J/pNrItkKz1mcvfwaqv4JsXTNxGiFDtNIo4d4aV7rbzdaqKLwZEpz8JwUzI+CbOX--CI1brbTk84ZXJ19+--KSyG1pYUx1cb6+LPcrsX6A== \ No newline at end of file diff --git a/config/deploy.yml b/config/deploy.yml index b60ff32..5fd74d5 100644 --- a/config/deploy.yml +++ b/config/deploy.yml @@ -40,7 +40,6 @@ env: secret: - RAILS_MASTER_KEY - POSTGRES_PASSWORD - - SMTP_PASSWORD - APP_VERSION # Use a different ssh user than root @@ -93,9 +92,9 @@ traefik: api.insecure: true entryPoints.web.address: ":80" entryPoints.websecure.address: ":443" - entryPoints.web.http.redirections.entryPoint.to: websecure - entryPoints.web.http.redirections.entryPoint.scheme: https - entryPoints.web.http.redirections.entrypoint.permanent: true + # entryPoints.web.http.redirections.entryPoint.to: websecure + # entryPoints.web.http.redirections.entryPoint.scheme: https + # entryPoints.web.http.redirections.entrypoint.permanent: true certificatesResolvers.letsencrypt.acme.email: "lorenzo.farnararo@gmail.com" certificatesResolvers.letsencrypt.acme.storage: "/letsencrypt/acme.json" certificatesResolvers.letsencrypt.acme.httpchallenge: true diff --git a/config/environments/production.rb b/config/environments/production.rb index f1140f3..f9c0176 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -82,13 +82,13 @@ # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false + config.action_mailer.raise_delivery_errors = false config.action_mailer.smtp_settings = { address: ENV.fetch('SMTP_ADDRESS', 'smtp.ionos.it'), port: ENV.fetch('SMTP_PORT', 587), user_name: ENV.fetch('SMTP_USERNAME', 'info@opengas.eu'), - password: ENV.fetch('SMTP_PASSWORD', 'password'), + password: Rails.application.credentials.dig(:smtp, :password), authentication: 'plain', enable_starttls: true } diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 81c80bb..754a025 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -183,7 +183,7 @@ # Email regex used to validate email formats. It simply asserts that # one (and only one) @ exists in the given string. This is mainly # to give user feedback and not to assert the e-mail validity. - config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ + config.email_regexp = URI::MailTo::EMAIL_REGEXP # ==> Configuration for :timeoutable # The time you want to timeout the user session without activity. After this