Allow customizing Redis database numbers for caching, background jobs and websocket connections.

This commit is contained in:
Eugene Burmakin 2025-07-02 21:22:31 +02:00
parent 787dd9cde8
commit 0fcf70834e
7 changed files with 9 additions and 8 deletions

View file

@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## Fixed ## Fixed
- Buttons on the imports page now looks better in both light and dark mode. #1481 - Buttons on the imports page now looks better in both light and dark mode. #1481
- The PROMETHEUS_EXPORTER_ENABLED environment variable default value is now "false", in quotes.
- The RAILS_CACHE_DB, RAILS_JOB_QUEUE_DB and RAILS_WS_DB environment variables can be used to set the Redis database number for caching, background jobs and websocket connections respectively. Default values are now 0, 1 and 2 respectively. #1420
# [0.29.0] - 2025-07-02 # [0.29.0] - 2025-07-02

View file

@ -1,7 +1,6 @@
# 🌍 Dawarich: Your Self-Hosted Location History Tracker # 🌍 Dawarich: Your Self-Hosted Location History Tracker
[![Discord](https://dcbadge.limes.pink/api/server/pHsBjpt5J8)](https://discord.gg/pHsBjpt5J8) | [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/H2H3IDYDD) | [![Patreon](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Dfreika%26type%3Dpatrons&style=for-the-badge)](https://www.patreon.com/freika) [![Discord](https://dcbadge.limes.pink/api/server/pHsBjpt5J8)](https://discord.gg/pHsBjpt5J8) | [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/H2H3IDYDD) | [![Patreon](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Dfreika%26type%3Dpatrons&style=for-the-badge)](https://www.patreon.com/freika)
Donate using crypto: [0x6bAd13667692632f1bF926cA9B421bEe7EaEB8D4](https://etherscan.io/address/0x6bAd13667692632f1bF926cA9B421bEe7EaEB8D4)
[![CircleCI](https://circleci.com/gh/Freika/dawarich.svg?style=svg)](https://app.circleci.com/pipelines/github/Freika/dawarich) [![CircleCI](https://circleci.com/gh/Freika/dawarich.svg?style=svg)](https://app.circleci.com/pipelines/github/Freika/dawarich)

View file

@ -1,11 +1,11 @@
development: development:
adapter: redis adapter: redis
url: <%= "#{ENV.fetch("REDIS_URL")}/2" %> url: <%= "#{ENV.fetch("REDIS_URL")}/#{ENV.fetch('RAILS_WS_DB', 2)}" %>
test: test:
adapter: test adapter: test
production: production:
adapter: redis adapter: redis
url: <%= "#{ENV.fetch("REDIS_URL")}/2" %> url: <%= "#{ENV.fetch("REDIS_URL")}/#{ENV.fetch('RAILS_WS_DB', 2)}" %>
channel_prefix: dawarich_production channel_prefix: dawarich_production

View file

@ -26,7 +26,7 @@ Rails.application.configure do
# Enable/disable caching. By default caching is disabled. # Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching. # Run rails dev:cache to toggle caching.
config.cache_store = :redis_cache_store, { url: "#{ENV['REDIS_URL']}/0" } config.cache_store = :redis_cache_store, { url: "#{ENV['REDIS_URL']}/#{ENV.fetch('RAILS_CACHE_DB', 0)}" }
if Rails.root.join('tmp/caching-dev.txt').exist? if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true config.action_controller.perform_caching = true

View file

@ -73,7 +73,7 @@ Rails.application.configure do
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info') config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')
# Use a different cache store in production. # Use a different cache store in production.
config.cache_store = :redis_cache_store, { url: "#{ENV['REDIS_URL']}/0" } config.cache_store = :redis_cache_store, { url: "#{ENV['REDIS_URL']}/#{ENV.fetch('RAILS_CACHE_DB', 0)}" }
# Use a real queuing backend for Active Job (and separate queues per environment). # Use a real queuing backend for Active Job (and separate queues per environment).
config.active_job.queue_adapter = :sidekiq config.active_job.queue_adapter = :sidekiq

View file

@ -4,7 +4,7 @@ settings = {
debug_mode: true, debug_mode: true,
timeout: 5, timeout: 5,
units: :km, units: :km,
cache: Redis.new(url: "#{ENV['REDIS_URL']}/0"), cache: Redis.new(url: "#{ENV['REDIS_URL']}/#{ENV.fetch('RAILS_CACHE_DB', 0)}"),
always_raise: :all, always_raise: :all,
http_headers: { http_headers: {
'User-Agent' => "Dawarich #{APP_VERSION} (https://dawarich.app)" 'User-Agent' => "Dawarich #{APP_VERSION} (https://dawarich.app)"

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
Sidekiq.configure_server do |config| Sidekiq.configure_server do |config|
config.redis = { url: "#{ENV['REDIS_URL']}/1" } config.redis = { url: "#{ENV['REDIS_URL']}/#{ENV.fetch('RAILS_JOB_QUEUE_DB', 1)}" }
config.logger = Sidekiq::Logger.new($stdout) config.logger = Sidekiq::Logger.new($stdout)
if ENV['PROMETHEUS_EXPORTER_ENABLED'].to_s == 'true' if ENV['PROMETHEUS_EXPORTER_ENABLED'].to_s == 'true'
@ -24,7 +24,7 @@ Sidekiq.configure_server do |config|
end end
Sidekiq.configure_client do |config| Sidekiq.configure_client do |config|
config.redis = { url: "#{ENV['REDIS_URL']}/1" } config.redis = { url: "#{ENV['REDIS_URL']}/#{ENV.fetch('RAILS_JOB_QUEUE_DB', 1)}" }
end end
Sidekiq::Queue['reverse_geocoding'].limit = 1 if Sidekiq.server? && DawarichSettings.photon_uses_komoot_io? Sidekiq::Queue['reverse_geocoding'].limit = 1 if Sidekiq.server? && DawarichSettings.photon_uses_komoot_io?