Skip to content

Instantly share code, notes, and snippets.

@ityonemo
Created December 13, 2022 15:34
Show Gist options
  • Save ityonemo/177cbc96f8c8722bfc4d127ff9baec62 to your computer and use it in GitHub Desktop.
Save ityonemo/177cbc96f8c8722bfc4d127ff9baec62 to your computer and use it in GitHub Desktop.
starts a BEAM peer node
:net_kernel.start([:"[email protected]"])
:erlang.set_cookie(:cook)
{:ok, peer, peername} =
:peer.start(%{connection: 0, name: :peer, host: ~C'127.0.0.1'})
:peer.call(peer, :erlang, :set_cookie, [:cook])
Node.connect(peername)
# add code paths
:rpc.call(peername, :code, :add_paths, [:code.get_path()])
# setup all application config
for {app_name, _, _} <- Application.loaded_applications() do
for {key, val} <- Application.get_all_env(app_name) do
:rpc.call(peername, Application, :put_env, [app_name, key, val])
end
end
# start all applications
:rpc.call(peername, Application, :ensure_all_started, [:mix])
:rpc.call(peername, Mix, :env, [Mix.env()])
for {app_name, _, _} <- Application.loaded_applications() do
:rpc.call(peername, Application, :ensure_all_started, [app_name])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment