peter.bocian

peter.bocian

Hi Elixir team! I am new to this forum. I currently moved to redis sentinel and although production is working fine I am having trouble getting my tests to pass. The error I am seeing is: ** (Mix) Could not start application scrivener: Scrivener.start(:normal, []) returned an error: shutdown: failed to start child: :worker ** (EXIT) an exception was raised: ** (MatchError) no match of right hand side value: {:error, {:EXIT, {%ArgumentError{message: "sentinel address should be specified as a URI or a keyword list, got: nil"}, [{Redix.StartOptions, :normalize_sentinel_address, 2, [file: 'lib/redix/start_options.ex', line: 122]}, {Enum, :"-map/2-lists^map/1-0-", 2, [file: 'lib/enum.ex', line: 1411]}, {Redix.StartOptions, :sanitize_sentinel_opts, 1, [file: 'lib/redix/start_options.ex', line: 79]}, {Redix.StartOptions, :maybe_sanitize_sentinel_opts, 1, [file: 'lib/redix/start_options.ex', line: 68]}, {Redix.StartOptions, :sanitize, 1, [file: 'lib/redix/start_options.ex', line: 51]}, {Redix.Connection, :start_link, 1, [file: 'lib/redix/connection.ex', line: 25]}, {:supervisor, :do_start_child_i, 3, [file: 'supervisor.erl', line: 385]}, {:supervisor, :handle_call, 3, [file: 'supervisor.erl', line: 410]}]}}} (poolboy 1.5.1) src/poolboy.erl:275: :poolboy.new_worker/1 . My test.exs is set up exactly like my prod.exs => ```config :scrivener, Scrivener.Endpoint,
http: [:inet6, port: {:system, “PORT”}],
server: false

Do not print debug messages in production

config :logger, level: :warn

Pull Redis sentinel settings from environment variables

{ redis_pool_size, original_value } = (System.get_env(“REDIS_POOL_SIZE”) || “5”) |> Integer.parse
{ redis_max_overflow, original_value } = (System.get_env(“REDIS_MAX_OVERFLOW”) || “2”) |> Integer.parse
{ redis_sentinel_timeout, original_value } = (System.get_env(“REDIS_SENTINEL_TIMEOUT”) || “10000”) |> Integer.parse

config :redix,
pool_size: redis_pool_size,
max_overflow: redis_max_overflow,
sentinel: [
sentinels: [
System.get_env(“REDIS_SENTINEL_HOST_A”),
System.get_env(“REDIS_SENTINEL_HOST_B”),
System.get_env(“REDIS_SENTINEL_HOST_C”)
],
group: System.get_env(“REDIS_SENTINEL_GROUP”),
timeout: redis_sentinel_timeout
]```. I can see it is a redix issue but not sure how to resolve.

Showing Posts 1 to 5

al2o3cr

al2o3cr

I suspect one of these environment variables isn’t set, that would explain finding a nil in sentinels

peter.bocian

peter.bocian OP

Thanks for the fast reply. By checking my environment variables, I have them connected and they are working in production. I am wondering if it could be a gem/version thing for mix? REDIS_SENTINEL_HOST_A=redis://sentinel004…
REDIS_SENTINEL_HOST_B=redis://sentinel005…
REDIS_SENTINEL_HOST_C=redis://sentinel006…

al2o3cr

al2o3cr

Try inspecting the values in the config; something is not making it to Redix.

config :redix,
  pool_size: redis_pool_size,
  max_overflow: redis_max_overflow,
  sentinel: [
    sentinels: [
      System.get_env(“REDIS_SENTINEL_HOST_A”),
      System.get_env(“REDIS_SENTINEL_HOST_B”),
      System.get_env(“REDIS_SENTINEL_HOST_C”)
    ] |> IO.inspect(label: "sentinel list"),
    group: System.get_env(“REDIS_SENTINEL_GROUP”),
    timeout: redis_sentinel_timeout
  ]
peter.bocian

peter.bocian OP

Thank you :bowing_man:. It looks like when printing they were coming in as null. I hardcoded redis sentinel endpoints and following error: {%ArgumentError{message: “a host should be specified for each sentinel”}. When looking in redix docs, I see {Redix supports Redis Sentinel by passing a :sentinel
option to start_link/1 (or start_link/2) instead of :host and :port.}. Which is how it looks like I set it up.

vschroeder

vschroeder

It is unclear from the last message if you managed to solve this issue or not, but the fact that your settings were printed as nil would indicate that you tried to set the values using environment variables during runtime, hoping that they would be injected in the config. However, that code that is actually executed at compile-time.

You mentioned the injection of these variables in your config/test.exs and config/prod.exs reinforces my impression. Most likely, you have such variables correctly set in your test suite, but you most certainly don’t have them when compiling your code for production. Both config files mentioned above are only executed during compile-time, and therefor, only use the environment variables available at that point in time. Setting these variables later, when running the application, is irrelevant.

The only config file executed during runtime is config/releases.exs, but obviously only in the context of a release, which is what you should be running in production anyway.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews