I’m experiencing some odd behavior. I’m using mongodb_driver
(v0.9.0) in an app (app1), and it’s been working great. But suddenly, when I use that app as a dependency (by app2), suddenly all my mongo queries time out.
My guess is that I’m stepping into something tricky with supervisors or something. (Why am I doing this? My thought was that app1
defines all the schemas and contexts for how to access resources, and I didn’t want to duplicate any of that in app2
– I want app2
to be ignorant about the “implementation details”).
app1
wraps the Mongo start like this:
def MyMongoWrapper do
def start_link(opts \\ []) do
# Read some config here... user, password, etc.
Mongo.start_link(opts)
end
end
which is ref’d in app1
’s application.ex:
def start(_type, _args) do
children = [
{MyMongoWrapper, []}
]
opts = [strategy: :one_for_one, name: App1.Supervisor]
Supervisor.start_link(children, opts)
end
So all is well with the world in app1
: I can start it up and make queries as expected.
But when I start working with app2
and I use app1
as a dependency, nothing seems to work, even though app1
DOES get started and the mongo process DOES get started.
Instead of relying on “implicit starting” (?) that happens when an app lists another app as a dependency, I tried manually listing App1
in app2
’s supervision tree, but calls to Mongo still time out.
Likewise, if I remove all the children from app1
’s application.ex
and list the MyMongoWrapper
in app2
’s application.ex
, I get the same result: any Mongo queries cause an exit due to timeout.
It’s really making me scratch my head and wonder why things are working in app1
at all. The config and everything seems to be exactly the same.
Does anyone have any ideas of what might be causing this type of behavior or other things I could check?