gleam
gleam copied to clipboard
Starting in distributed mode
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"),
])
}
Related to this, when starting in distributed mode, epmd should also be started.
Thank you
@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
I wasn't aware of that option, thanks :) Still think this should be visible to people that aren't veterans in BEAM configuration.
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!
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?
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.