I want to use MongoDB and ConCaache worker in my app, but when I tried the following
def start(_type, _args) do
import Supervisor.Spec
# List all child processes to be supervised
children = [
# Start the endpoint when the application starts
supervisor(MyAppWeb.Endpoint, []),
# Starts a worker by calling: MyAppWeb.Worker.start_link(arg)
# {MyAppWeb.Worker, arg},
worker(Mongo, [[database:
Application.get_env(:mong, :db)[:name], name: :mongo, pool_size: 100]]),
worker(ConCache, [name: :my_cache, ttl_check_interval: false])
]
I get the following error when running
[info] Application my_app exited: exited in: MyApp.Application.start(:normal, [])
** (EXIT) exited in: GenServer.call(:mongo, :topology, 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
** (Mix) Could not start application my_app: exited in MyApp.Application.start(:normal, [])
** (EXIT) exited in: GenServer.call(:mongo, :topology, 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
There is nothing obviously incorrect with the code example you have shared. Would you be able to share a minimal repoduction of the project so that we can run and debug the problem? Thanks
I have changed the code to this and I don’t know why but it worked perfectly
def start(_type, _args) do
import Supervisor.Spec
# List all child processes to be supervised
children = [
# Start the endpoint when the application starts
supervisor(MyAppWeb.Endpoint, []),
# Starts a worker by calling: MyAppWeb.Worker.start_link(arg)
# {MyAppWeb.Worker, arg},
worker(Mongo, [[database:
Application.get_env(:mong, :db)[:name], name: :mongo, pool_size: 100]]),
{ConCache, [name: :my_cache, ttl_check_interval: false]}
]