din_S
I want to run different instances of the same app (not copies of the same app) on the same server (clustering) using different ports, so I used libcluster library and did the following (in application.ex):
def start(_type, _args) do
import Supervisor.Spec
# Define Topologies for clustering
topologies = [
example: [
strategy: Cluster.Strategy.Gossip
]
]
# List all child processes to be supervised
children = [
# For Clustering
{Cluster.Supervisor, [topologies, [name: MyApp.ClusterSupervisor]]},
# Start the endpoint when the application starts
supervisor(MyAppWeb.Endpoint, []),
{ConCache, [name: :my_cache, ttl_check_interval: false]}
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
result = Supervisor.start_link(children, opts)
end
I even tried this:
topologies = [
example: [
strategy: Cluster.Strategy.Gossip,
config: [hosts: [:"a@127.0.0.1", :"b@127.0.0.1",:"b@127.0.0.1",:"d@127.0.0.1"]],
]
]
but when I tried the following on the server (Ubuntu 18):
PORT=3000 elixir --sname a -S mix phx.server
then
PORT=3001 elixir --sname b -S mix phx.server
I get the following error
** (Mix) Could not start application my_app: MyApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: MyAppWeb.Endpoint
** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, MyAppWeb.Endpoint.HTTP}
** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
** (EXIT) {:listen_error, MyAppWeb.Endpoint.HTTP, :eaddrinuse}
what should I do to make it work.
Trending in Questions
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
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
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
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
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
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex











Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
kokolegorille
You should check after starting first server if port 3000 is answering, if not, check port 4000.
I usually have to update my dev config file to do this…
… and then I can pass PORT on startup.
din_S
After starting the first server, the application is answering correctly on the port,
because my config is like this
the problem is in running the app on other ports on the same time
kokolegorille
I have tested this on a Phoenix without libcluster and it works for me.
I also have a libcluster, swarm project, but it uses Cowboy instead of Phoenix.
This might not help You, but I use Epmd strategy, and my config is standard to libcluster doc.
and I start nodes like this
It works, but this is not using Phoenix, but Cowboy.
din_S
Just a question, why it worked with the previous command and not this command
and would the apps work without determining phx.server or not ?
and when I tried this command
netstat -nlp | grep beamI got the following output (without 3001 or 3002)
ofcourse
sudo netstat -nlp | grep 3001andsudo netstat -nlp | grep 3002give me nothingdin_S
I tried the other approach and it worked correctly, thanks a lot
but it really bothers me that it didn’t work with libcluster and without knowing why
Mack_Akdas
Hi Din_s,
I see a replication, maybe irrelevant to what you are looking for, but this should not be there, shouldn’t that not be a ‘c’ ?