pg_rails 7.0.8.pre.alpha.92 → 7.0.8.pre.alpha.93

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1d03457f0e56b9231502b27a4c8574f87122439c35eb39628fa2e24b50940ba
4
- data.tar.gz: f8e64ab521583640302b4fe5ae31306fa68434d7ad74a397767b35e48a4995ab
3
+ metadata.gz: bdf7d3d8c84262ae3dbb580c76a11f33d9cb91a6168ec187dfd0f760a080fde6
4
+ data.tar.gz: ebb7a5b8d8680a82f71574c04efe8f517b04134c628e6cd10103828d34d78727
5
5
  SHA512:
6
- metadata.gz: 1a075b979d181e36c0297f46896cdedb424b50d31c56b6bb2d340a8c9110f4f55e6dc0c19425011e1434838b83cdd5f3d1ef9f6790b35259a4bf86b9cf7db23c
7
- data.tar.gz: 3c031aff35b7afe32b21e1516b006848e2c736bc07691996f66eea3d47b7542f1e39bd2610d2222d58737a442918b965e1f68dbae562e97ef60f2d765ae90516
6
+ metadata.gz: 82cc777c32238b7c5430a95c6ebf701b188cb94b885373e43d1b20976e4081f3c6fa7ce0366cd8c5ed455cd9375fac70b2e7c5fdff3ea1d258f6cb546f6709ec
7
+ data.tar.gz: 84c40fd802a3681eeb76c11e0de4e5280bc41d9e97cf88a5a74a71b396c02dd7e68af0985a541325a1be9b26e692d0d35e893c37d16849b53a114fc4cebdf522
@@ -0,0 +1,42 @@
1
+ module PgEngine
2
+ class HealthController < ApplicationController
3
+ rescue_from(Exception) do |error|
4
+ pg_err error
5
+ render_down
6
+ end
7
+
8
+ def show
9
+ check_redis
10
+ check_postgres
11
+ render_up
12
+ end
13
+
14
+ private
15
+
16
+ def check_postgres
17
+ return if User.count.is_a? Integer
18
+
19
+ raise PgEngine::Error, 'postgres is down'
20
+ end
21
+
22
+ def check_redis
23
+ return if Kredis.counter('healthcheck').increment.is_a? Integer
24
+
25
+ raise PgEngine::Error, 'redis is down'
26
+ end
27
+
28
+ def render_up
29
+ render html: html_status(color: '#005500')
30
+ end
31
+
32
+ def render_down
33
+ render html: html_status(color: '#990000'), status: :internal_server_error
34
+ end
35
+
36
+ def html_status(color:)
37
+ # rubocop:disable Rails/OutputSafety
38
+ %(<!DOCTYPE html><html><body style="background-color: #{color}"></body></html>).html_safe
39
+ # rubocop:enable Rails/OutputSafety
40
+ end
41
+ end
42
+ end
@@ -1,6 +1,7 @@
1
1
  include PgEngine::RouteHelpers
2
2
 
3
3
  Rails.application.routes.draw do
4
+ get "pg_engine/health" => "pg_engine/health#show", as: :pg_engine_health_check
4
5
  namespace :public, path: '' do
5
6
  pg_resource(:mensaje_contactos, only: [:new, :create], path: 'contacto')
6
7
  post 'webhook/mailgun', to: 'webhooks#mailgun'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.92'
4
+ VERSION = '7.0.8-alpha.93'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.8.pre.alpha.92
4
+ version: 7.0.8.pre.alpha.93
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-08 00:00:00.000000000 Z
11
+ date: 2024-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -983,6 +983,7 @@ files:
983
983
  - pg_engine/app/controllers/concerns/pg_engine/resource.rb
984
984
  - pg_engine/app/controllers/pg_engine/base_controller.rb
985
985
  - pg_engine/app/controllers/pg_engine/devise_controller.rb
986
+ - pg_engine/app/controllers/pg_engine/health_controller.rb
986
987
  - pg_engine/app/controllers/pg_engine/require_sign_in.rb
987
988
  - pg_engine/app/controllers/public/mensaje_contactos_controller.rb
988
989
  - pg_engine/app/controllers/public/webhooks_controller.rb