txty-io / texterify

The translation and localization management system.
https://texterify.com
Other
169 stars 14 forks source link

Unable to get the REDIS_URL configuration in the environment variable #151

Closed jinrenjie closed 1 year ago

jinrenjie commented 1 year ago
$ sudo docker compose ps
WARN[0000] volume texterify-assets: volume.external.name is deprecated in favor of volume.name
WARN[0000] volume texterify-database: volume.external.name is deprecated in favor of volume.name
NAME                  IMAGE                       COMMAND                  SERVICE             CREATED             STATUS              PORTS
texterify-db-1        postgres:12.2               "docker-entrypoint.s…"   db                  6 minutes ago       Up 5 minutes        0.0.0.0:5432->5432/tcp, :::5432->5432/tcp
texterify-redis-1     redis:6.2.0-alpine          "docker-entrypoint.s…"   redis               23 hours ago        Up 5 minutes        6379/tcp
texterify-sidekiq-1   chrztoph/texterify:v1.2.0   "bundle exec sidekiq"    sidekiq             6 minutes ago       Up 5 minutes        3000/tcp
$ sudo docker inspect texterify-sidekiq-1 | grep REDIS_URL
                "REDIS_URL=redis://:password@redis:6379/0",
$ sudo docker compose logs sidekiq
WARN[0000] volume texterify-database: volume.external.name is deprecated in favor of volume.name
WARN[0000] volume texterify-assets: volume.external.name is deprecated in favor of volume.name
texterify-sidekiq-1  | 2023-03-09T05:55:14.681Z pid=1 tid=6l9 INFO: Booting Sidekiq 6.4.1 with redis options {:url=>"redis://redis:6379/0"}
texterify-sidekiq-1  | 2023-03-09T05:55:15.941Z pid=1 tid=6l9 INFO: Booted Rails 6.1.3.1 application in production environment
texterify-sidekiq-1  | 2023-03-09T05:55:15.941Z pid=1 tid=6l9 INFO: Running in ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
texterify-sidekiq-1  | 2023-03-09T05:55:15.941Z pid=1 tid=6l9 INFO: See LICENSE and the LGPL-3.0 for licensing details.
texterify-sidekiq-1  | 2023-03-09T05:55:15.941Z pid=1 tid=6l9 INFO: Upgrade to Sidekiq Pro for more features and support: https://sidekiq.org
texterify-sidekiq-1  | 2023-03-09T05:55:15.947Z pid=1 tid=6l9 INFO: Loading Schedule
texterify-sidekiq-1  | 2023-03-09T05:55:15.947Z pid=1 tid=6l9 INFO: Scheduling TrialEndingWorker {"cron"=>"0 4 * * *", "class"=>"TrialEndingWorker", "queue"=>"default"}
texterify-sidekiq-1  | 2023-03-09T05:55:15.949Z pid=1 tid=6l9 INFO: Scheduling DeeplSupportedLanguagesWorker {"cron"=>"0 4 * * *", "class"=>"DeeplSupportedLanguagesWorker", "queue"=>"default"}
texterify-sidekiq-1  | 2023-03-09T05:55:15.950Z pid=1 tid=6l9 INFO: Scheduling ResetMachineTranslationCharactersUsageWorker {"cron"=>"0 4 1 * *", "class"=>"ResetMachineTranslationCharactersUsageWorker", "queue"=>"default"}
texterify-sidekiq-1  | 2023-03-09T05:55:15.955Z pid=1 tid=6l9 INFO: Schedules Loaded

As the above log shows, sidekiq is not using the REDIS_URL that I defined in .env file.

This caused me to always fail when connect to the existing external Redis Server, and the container could not run normally!

chrztoph commented 1 year ago

Hey,

currently the redis URL is hardcoded here: https://github.com/txty-io/texterify/blob/master/config/initializers/sidekiq.rb

I think adding a new env variable would solve your problem?

jinrenjie commented 1 year ago

@chrztoph Yes, my current solution is to directly modify the /var/www/texterify/config/initializers/sidekiq.rb file in the Docker image.

This is not a good solution, so I want to create a PR to fix this problem, but I'm not sure if the following code is Ruby syntactic, as I know nothing about Ruby 😂:

Sidekiq.configure_server { |config| config.redis = { url: "#{ENV.fetch('REDIS_URL', 'redis://redis:6379/0')}" } }

Sidekiq.configure_client { |config| config.redis = { url: "#{ENV.fetch('REDIS_URL', 'redis://redis:6379/0')}" } }
jinrenjie commented 1 year ago

I noticed you already fixed this in your commit.

Thank you so much!🍻