epailty

epailty

In my efforts to get UPGRADE working (for a Phoenix application) for exrm releases on Microsoft Windows, I noticed that I could not ping the node, even though it was running. So I checked and it was using nonde@nohost.

To solve this, I called these functions from the main application module:

:net_kernel.start([name, :longnames])
:erlang.set_cookie(node(), cookie)

This works (at least it starts the node properly), but its not a proper solution.

erlsrv is being passed the node name by the application release bat file, but it seems that its not being set when the application is actually started.

I approached this initially thinking I needed to get this working quickly for operational purposes, but now want to do it properly by patching something in erlsrv.c or in the batch files.

For your information, the following code is how I got my application working:

  use Application

  @version Mix.Project.config[:version]
  def version(), do: @version

  @env Mix.env
  def env(), do: @env

  defp start_network(name, cookie) when is_atom(name) do
    case :net_kernel.start([name, :longnames]) do
      {:ok, pid} -> :erlang.set_cookie(node(), cookie)
      {:error, {{:already_started, pid}, _}} -> :already_started
    end
  end

  defp get_vm_args() do
    {:ok, data} = File.read(Path.expand("../../releases/#{version()}/vm.args", System.cwd!()))
  end

  defp get_node_name(data) do
    case Regex.run(~r/-name ([^\n]+)/, data) do
      nil -> nil
      [_, name] -> String.to_atom(name)
    end
  end

  defp get_cookie(data) do
    case Regex.run(~r/-setcookie ([^\n]+)/, data) do
      nil -> nil
      [_, cookie] -> String.to_atom(cookie)
    end
  end

  def start(_type, _args) do
    import Supervisor.Spec

    if node() == :nonode@nohost and env() == :prod do
      data = get_vm_args()
      node_name = get_node_name(data)
      cookie = get_cookie(data)
      start_network(node_name, cookie)
    end

… followed by the normal supervision startup stuff.

I will be deleting this code once I get erlsrv.c patched, so I’m not really posting this asking for advice about how to do it in Elixir, this is to illustrate what I needed to do, i.e. what erlsvr.c is not doing now. I’m posting here, hoping for help regarding erlsvr.c and the batch files

Thanks

Showing Posts 1 to 6

epailty

epailty OP

I noticed that the install_upgrade.escript in exrm, called also from relx needs to be passed a first parameter of “install”. This also needs to be fixed, otherwise the upgrade still does not work.

      {:relx, github: "bmodra/relx", override: true},
      {:exrm, github: "bmodra/exrm", override: true},

… I am working on some changes … The changes to my forks above work for upgrade.
Next I will work on the start/install scripts and possibly erlsrv.c

epailty

epailty OP

boot.bat (in exrm) was initialising conform_opts to "", as if that was an empty string, but in a bat file its not:

@set conform_opts=""

This code was failing:

:install
@if "" == "%2" (
  :: Install the service
  set args=%erl_opts% %conform_opts% -setcookie %cookie% ++ -rootdir \"%rootdir%\"
  set svc_machine=%erts_dir%\bin\start_erl.exe
  set description=Erlang node %node_name% in %rootdir%
  %erlsrv% add %service_name% %node_type% "%node_name%" -c "%description%" ^
            -w "%rootdir%" -m "%svc_machine%" -args "%args%" ^
            -stopaction "init:stop()."

The args string had "" before the rest of the arguments (e.g. -setcookie…) whch caused them to be removed (due to how batch file arguments get expanded)
So I changed the initialisation to:

@set conform_opts=
OvermindDL1

OvermindDL1

I run substantially changed exrm windows bat files that I’ve edited over time… Never committed them back since exrm was being replaced by distillary (does it have Windows support yet?). A lot of those changes look very familiar, including others I have… ^.^;

bitwalker

bitwalker

Leader

Just chiming in to say that yes, Distillery has windows support now :). If you wouldn’t mind taking a look at the new batch scripts and giving them a review, it would be much appreciated!

OvermindDL1

OvermindDL1

WHOO! We are in a crunch period at work currently but I will do that before the next deployment and report any issues found. :slight_smile:

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
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
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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