UlrikHD

UlrikHD

How to stop mix to hard code a Node name for application release?

I got an application where I’d like to start the node with a (long) name dynamically determined during runtime based on the computer’s IP address. However when I run mix release the application is given a node at compile time. I can’t for the life of me get anything useful out the mix release docs

So my question is, how do configure my project to not start the system with a pre-defined node.

Bonus question would be why does mix release hard code a node name? Won’t it make it impossible to differentiate between two nodes of the same application?

This is mostly what’s in my mix.exs

defmodule Elevator.MixProject do
  use Mix.Project

  def project do
    [
      app: :elevator,
      version: "0.8.0",
      elixir: "~> 1.13",
      start_permanent: Mix.env() == :prod,
      env: Mix.env(),
      releases: [
        win_debug: [
          include_executables_for: [:windows],
          applications: [runtime_tools: :permanent],
          path: "releases/win_debug/"
        ],
        lab_debug: [
          include_executables_for: [:unix],
          applications: [runtime_tools: :permanent],
          path: "releases/lab_debug/"
        ]
      ]
    ]
  end

  def application() do
    [
      extra_applications: [:logger, :runtime_tools],
      mod: {Main, []}
      # Switch with Main to simulate single elevator
      # mod: {ElevatorSimul, []}
    ]
  end
end

Marked As Solved

UlrikHD

UlrikHD

After trawling through elixir repos on Github for hints, I got a working solution by creating a file rel/env.bat.eex with the lines:

@echo off
set RELEASE_DISTRIBUTION=none

This disables the application from starting up Node, so that we can manually control it via Node.start/3

I also got a file rel/env.sh.eex that I assume will apply the same changes on Linux.

#!/bin/sh

export RELEASE_DISTRIBUTION=none

Also Liked

kokolegorille

kokolegorille

You could also have used

mix release --init

It creates the rel folder and files automatically

UlrikHD

UlrikHD

C:\Users\UlrikHD\Documents\test> mix release --init
** (Mix) Could not invoke task "release": 1 error found!
--init : Unknown option

It’s mix release.init as of elixir 1.18 (just in case someone stumbles over it)

Thanks for the tip though, it might help others that stumbles over a similar problem

Where Next?

Popular in Questions Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
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
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
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
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
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
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
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
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
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
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
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
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement