elmercante

elmercante

How can you run multiple applications on one BEAM instance with MainProxy?

Hi @axelson, thanks for putting together main_proxy. I want to use it to do the same thing you’ve used it for: running multiple applications from one BEAM instance. I have an umbrella application with three phoenix endpoints (3 separate child apps): one for an e-commerce shop, another for the store’s admin area, and a third for its cms admin area. I want to route the requests for the admin areas to the single exposed web port for the e-commerce shop since the other two will never see much traffic. However, I’m having difficulty getting it to work with my release.

I have the functionality working correctly in both my local dev and prod environments, but once I use mix release to produce a release nothing is served when I start it. I’m seeing logs such as Configuration :server was not enabled for MyAppWeb.Endpoint, http/https services won't start for each web app that I’m trying to spin up locally in my release. Upon deployment (we build & start the release on Render) I’m seeing those logs plus the following ==> No open HTTP ports detected on 0.0.0.0, continuing to scan...

Do you have any idea what the issue could be?

Marked As Solved

hubertlepicki

hubertlepicki

Two suspects:

  1. Are you starting MyApp.Proxy (or whatever you called it) in your application.ex in the supervision tree? This is this step in the readme:
children = [
  # ... other children
  MyApp.Proxy,
]

This should be done in one of the applications you have in app/. In my case I created a separate application just to serve that.

  1. Are you including and starting the application mentioned in the paragraph above (may be your “ui” or “web” app too if you don’t use dedicated one for proxy) in the release configuration?

You should have something like this in the top-level mix.exs of your project

deps: deps(),
releases: releases()
...

defp releases do
  [
    my_app: [
      applications: [
         proxy: :permanent
         ...
       ]
    ]
  end

I strongly suspect you’re not doing 1 or 2 or both and the OTP application that should have main proxy as a child either does not start at all, or does not start the child.

Also Liked

stefanluptak

stefanluptak

If the RENDER_EXTERNAL_HOSTNAME is app-123.onrender.com for example, then it means that for MyCmsWeb and MyAppAdminWeb to work, domains my-cms.app-123.onrender.com and my-admin.app-123.onrender.com would have to exist, but that’s not the case, because you’re not able to create DNS records for onrender.com subdomains.

If you don’t want to use your own custom domain, you should probably use :path instead of :domain.
But I suggest to set up your custom domain. Then save it’s value to a CUSTOM_DOMAIN env var for example and use that one in your MyAppProxy.Proxy code instead of the RENDER_EXTERNAL_HOSTNAME.

stefanluptak

stefanluptak

I think there could be a mismatch between your backends specification and the custom domains (with certificates) you set-up in the render.com settings for your app.
EDIT: I ran few apps with MainProxy on render.com successfully.

elmercante

elmercante

Ok I gave :path a try, but the problem I’m running into now is that the cms is taking up all the spare paths. That is to say all the paths which aren’t already defined in the router file as routes for the app’s functionality are reserved for the cms. There’s probably a way to skirt around this, but I’d prefer not to complicate things further.

I think the only way forward is to use a custom domain as you suggested, but I was hoping to test things out with Render’s provided onrender.com subdomain first. I’ll continue to experiment with this and I’ll drop an update here if there’s anything useful to share. Thanks for your help @stefanluptak!

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
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
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
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

We're in Beta

About us Mission Statement