francois1

francois1

Failed to start child: ** (EXIT) already started

I want to share a Finch app among Umbrella apps.

  • In foo_app:
  def start(_type, _args) do
    children = [
      {Finch, name: MyAppServer.Finch},
  • In bar_app:
  def start(_type, _args) do
    children = [
      {Finch, name: MyAppServer.Finch},

This leads to the error:

Application bar_app exited: BarApp.Application.start(:normal, ) returned an error: shutdown: failed to start child: MyAppServer.Finch

Is there any way to start the app only if not already available?

Other options:

  • start it only from one of the apps
    => but what if I want to start the other app (which wouldn’t start Finch) independently

  • use 2 Finch instances
    => the Swoosh mailer accepts only one Finch instance

  • start it in a shared app
    => ultimately possible if no other easier solution

Most Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

You aren’t starting an app, you are defining an instance of Finch, monitored in your apps supervision tree, with a name. You’re explicitly starting it twice with the same name.

If you plan to use it from Swoosh and you want just one swoosh config then you should run finch in whatever app is using swoosh. If multiple apps are using swoosh then I would start two finch instances and configure each swoosh to use one.

Ultimately issues like this are why I abandoned umbrella apps. The “you might start parts of it separately” part was always theoretical, and the dependency struggles was always concrete and ever present.

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

That seems like a major deficiency in swoosh then. Most elixir apps have gone away from singleton configuration for this and other reasons.

Last Post!

francois1

francois1

In my case I have apps deployed independently. The reason I went for an Umbrella is that it is a well-documented setup for having one repo with multiple apps and shared dependencies, there is tooling provided such as running all tests from the root, run all apps at once in development, etc.
I could move away from Umbrella easily as those apps are not coupled except that they share some common files. Whether I use Umbrella or not, the alternative will result in nearly the same setup in my opinion… well, I could have configured Swoosh separately if I had totally separated apps without Umbrella.
I do not use Umbrella apps to enforce separation of concerns in code, but only to have a set of independently deployable apps that belong to one same suite of apps.

Deployment is not my forte. What I would do is simply have separate Finch instances and separate Swoosh configs, whether they are deployed on a same node or not, as it is the easiest to set up (i.e. just configure finch/swoosh for every app in the config file copy/paste:)) But again, Swoosh doesn’t allow that.

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
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
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
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

Other popular topics Top

hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
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
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31586 112
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement