Created
December 13, 2022 15:34
-
-
Save ityonemo/177cbc96f8c8722bfc4d127ff9baec62 to your computer and use it in GitHub Desktop.
starts a BEAM peer node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: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