gleam icon indicating copy to clipboard operation
gleam copied to clipboard

Starting in distributed mode

Open manveru opened this issue 3 years ago • 2 comments

There is no easy way to set the name/shortname and cookie via gleam run right now. It would be nice to have some form of command line flags for it.

workaround:

external fn net_kernel_start(
  List(atom.Atom),
) -> Result(process.Pid, dynamic.Dynamic) =
  "net_kernel" "start"

pub fn main() {
  net_kernel_start([
    atom.create_from_string("dilbert"),
    atom.create_from_string("shortnames"),
  ])
}

manveru avatar Sep 10 '22 13:09 manveru

Related to this, when starting in distributed mode, epmd should also be started.

manveru avatar Sep 10 '22 13:09 manveru

Thank you

lpil avatar Sep 10 '22 15:09 lpil

@manveru did you try to configure the ERL_AFLAGS environment variable previously to launch the Gleam project? Something like:

$ ERL_AFLAGS="-sname mynode@localhost -setcookie mycookie" gleam run

I tried that in my project and it worked perfectly:

$ ERL_AFLAGS="-sname mynode@localhost -setcookie mycookie" gleam shell
  Compiling ream
   Compiled in 0.05s
    Running Erlang shell
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns] [dtrace]

Eshell V13.2.2  (abort with ^G)
(mynode@localhost)1> erlang:get_cookie().
mycookie

manuel-rubio avatar May 17 '23 08:05 manuel-rubio

I wasn't aware of that option, thanks :) Still think this should be visible to people that aren't veterans in BEAM configuration.

manveru avatar Jun 18 '23 11:06 manveru

We don't currently have any special support for distributed computing. I would love to see what ideas and proposals people have for this area!

lpil avatar Jun 18 '23 13:06 lpil

we could probably document that gleam shell and gleam run --target erlang can be customized by erl/erlang specific env variables and point to those docs either as part of --help or in the guide?

inoas avatar Jun 18 '23 14:06 inoas

I don't want to document the BEAM APIs as it would just be duplicating their documentation. If we have documentation I would want it to be for whatever API we have considered and decided is the best fit for Gleam.

lpil avatar Jun 18 '23 15:06 lpil