bubiche

bubiche

Goth process not started for Phoenix application

I have something like below in my application.ex

children = [
  {Goth, name: MyApp.Goth},
  MyApp.SomeService,
  MyApp.Endpoint
]

opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)

SomeService looks like this:

defmodule MyApp.SomeService do
  use GenServer

  def start_link(opts \\ []) do
    GenServer.start_link(__MODULE__, opts)
  end

  def init(args) do
    {:ok, _} = Application.ensure_all_started(:goth)
    with token <- Goth.fetch!(MyApp.Goth) do
      # Use token, i.e. use it to fetch stuff from Google Cloud Secret Manager
    end

    {:ok, args}
  end
end

With the code above I get this error:

** (Mix) Could not start application myapp: exited in: MyApp.Application.start(:normal, [])
    ** (EXIT) exited in: GenServer.call({:via, Registry, {Goth.Registry, MyApp.Goth}}, :fetch, 5000)
        ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started

Is the call to Application.ensure_all_started not enough. Am I using goth and supervisor wrongly?

Most Liked

wojtekmach

wojtekmach

Hex Core Team

This is unexpected, the usage seems correct. Could you create a brand new mix project with just goth and verify it works? And then brand new Phoenix project with just goth?

Application.ensure_all_started(:goth) should not be needed if you add goth to your deps:

defp deps do
  [
    # ...
    {:goth, "~> 1.4"},
    # ...
  ]
end
wojtekmach

wojtekmach

Hex Core Team

I don’t think that’d work. I don’t know off the top my head when exactly child_spec/1 is being called by supervisor, ie whether it say computes all child specs first it calls them as it goes, but I have a feeling it is as if we wrote:

Goth.fetch!(MyGoth)

children = [
  {Goth, name: MyGoth},
]

which obviously won’t work

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

We're in Beta

About us Mission Statement