Hi,
I have a service with a couple of independent applications running together on the same machine. But two of these both want to start the same kind worker to access the same database. This gives me the following error:
** (Mix) Could not start application my_app: MyApp.Application.start(:normal, ) returned an error: shutdown: failed to start child: Bolt.Sips
** (EXIT) already started: #PID<1.2.3>
It all works fine if I just uncomment the worker in one of the applications when I run them together but that would be to (quite heavily) violate their independece. I also would prefer not to put them in some kind of umbrella due to the same, or atleast a similar, reason.
Is there some way I can give them different names, only start a second if one is already running or something of that sort?
In case it is relevant I use {:bolt_sips, “~> 0.4.12”} to connect to a neo4j database
Started this way:
def start(_type, _args) do
children = [
worker(Bolt.Sips, [Application.get_env(:bolt_sips, Bolt)])
]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end
With config similar to this:
config :bolt_sips, Bolt,
hostname: 'localhost',
basic_auth: [username: "xxx", password: "yyy"],
port: 7431,
pool_size: 5,
max_overflow: 1
(Where MyApp represents the two different application names)
*and yes, I know having two applications sharing the same database seems a bit dodgy when it comes to independence but because of reasons it turned out this way as they actually are two separate concerns.