1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-05 13:35:21 +02:00

Redis check for self hosted apps (#2353)

* Redis check for self hosted apps

* Run linter with autocorrect

* Add Redis to CI
This commit is contained in:
Zach Gollwitzer 2025-06-09 18:30:52 -04:00 committed by GitHub
parent 4044a8519f
commit 9fabcf4c72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 152 additions and 47 deletions

View file

@ -3,6 +3,8 @@ module SelfHostable
included do
helper_method :self_hosted?, :self_hosted_first_login?
prepend_before_action :verify_self_host_config
end
private
@ -13,4 +15,29 @@ module SelfHostable
def self_hosted_first_login?
self_hosted? && User.count.zero?
end
def verify_self_host_config
return unless self_hosted?
# Special handling for Redis configuration error page
if controller_name == "pages" && action_name == "redis_configuration_error"
# If Redis is now working, redirect to home
if redis_connected?
redirect_to root_path, notice: "Redis is now configured properly! You can now setup your Maybe application."
end
return
end
unless redis_connected?
redirect_to redis_configuration_error_path
end
end
def redis_connected?
Redis.new.ping
true
rescue Redis::CannotConnectError
false
end
end