francois1

francois1

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

Showing Posts 1 to 5

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.

francois1

francois1 OP

I’d go for this first but swoosh can just have one global configuration, not a config per app inside the umbrella:

The config for Swoosh looks like this:

config :swoosh, :api_client, Something.Finch
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.

dimitarvp

dimitarvp

I agree with Ben both that (1) umbrella apps are a trap and (2) Swoosh could have done its configuration setup better but having said that, why would you want to have separate API clients for both apps? Why not just one (and maybe give it a bigger connection pool)?

Though it’s not clear from your post how are your apps related (and are they started on separate nodes) so maybe my suggestion is not relevant.

francois1

francois1 OP

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.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
psy-q
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews