mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-08 20:46:16 +08:00
Mention remote execution smart cell on intro
This commit is contained in:
parent
1381650811
commit
100d88041b
1 changed files with 30 additions and 32 deletions
|
@ -224,17 +224,23 @@ let's check it out.
|
||||||
### Communication and automation of Elixir systems
|
### Communication and automation of Elixir systems
|
||||||
|
|
||||||
You may also deploy notebooks as applications that automate and monitor
|
You may also deploy notebooks as applications that automate and monitor
|
||||||
live Elixir systems. You will use the same techniques
|
live Elixir systems. By cliking on "+ Smart cell", you will find Livebook
|
||||||
[as in the deploy guide](/learn/notebooks/deploy-apps) and from there
|
provides a "Remote execution" widget, that allows you to configure the
|
||||||
directly connect to your cluster.
|
node name, cookie, and the code you want to execute on the remote node.
|
||||||
|
|
||||||
To do so, you need to ensure Livebook is deployed in the same network
|
The node and cookie information are configured directly in the production
|
||||||
as your existing system. Then use [`Node.set_cookie/2`](https://hexdocs.pm/elixir/Node.html#set_cookie/2)
|
system you want to connect to. For example, to connect to a
|
||||||
with the node you want to connect to and its cookie, and finally
|
[Phoenix application](https://phoenixframework.org/) running on your machine,
|
||||||
explicitly call [`Node.connect/1`](https://hexdocs.pm/elixir/Node.html#connect/1)
|
you may start it as follows:
|
||||||
to confirm the connection can be established successfully.
|
|
||||||
To execute code and retrieve data from the live node, use
|
```shell
|
||||||
[the `:erpc` module](https://www.erlang.org/doc/man/erpc.html).
|
$ iex --sname phoenix-app --cookie secret -S mix phx.server
|
||||||
|
```
|
||||||
|
|
||||||
|
With this information in hand, you can query and automate tasks within
|
||||||
|
existing Elixir systems. You may also mix remote execution with Livebook's
|
||||||
|
rich features to [deploy applications](/learn/notebooks/deploy-apps)
|
||||||
|
that interact with those clusters.
|
||||||
|
|
||||||
<!-- livebook:{"break_markdown":true} -->
|
<!-- livebook:{"break_markdown":true} -->
|
||||||
|
|
||||||
|
@ -245,33 +251,25 @@ responsible for evaluating your code. You can choose the runtime by clicking
|
||||||
the "Runtime" icon (<i class="ri-livebook-runtime"></i>) on the sidebar
|
the "Runtime" icon (<i class="ri-livebook-runtime"></i>) on the sidebar
|
||||||
(or by using the <kbd>s</kbd> <kbd>r</kbd> keyboard shortcut).
|
(or by using the <kbd>s</kbd> <kbd>r</kbd> keyboard shortcut).
|
||||||
|
|
||||||
By default, a new Elixir runtime is started (similarly to starting `iex`).
|
By default, a new Elixir runtime is started (similarly to starting `iex`)
|
||||||
You can click reconnect whenever you want to discard the current runtime and
|
for each notebook. You can click reconnect whenever you want to discard the
|
||||||
start a new one.
|
current runtime and start a new one.
|
||||||
|
|
||||||
You can also manually *attach* to an existing distributed node by picking
|
You can also manually *attach* to an existing node by picking the "Attached Node"
|
||||||
the "Attached Node" runtime. To do so, you will need the Erlang Name of
|
runtime. While in the previous section we used the "Remove execution" smart cell
|
||||||
the external node and its Erlang Cookie. For example, you can start a
|
to connect the default Livebook runtime to an existing node, the "Attached Node"
|
||||||
[Phoenix application](https://phoenixframework.org/) as follows:
|
will make it so the Livebook runtime itself runs within the external node.
|
||||||
|
|
||||||
```shell
|
To do so, open up a new notebook and click the "Runtime" icon on the sidebar.
|
||||||
$ iex --sname phoenix-app --cookie secret -S mix phx.server
|
|
||||||
```
|
|
||||||
|
|
||||||
Now open up a new notebook and click the "Runtime" icon on the sidebar.
|
|
||||||
Click to "Configure" the runtime and choose "Attached node". Input the
|
Click to "Configure" the runtime and choose "Attached node". Input the
|
||||||
name and cookie as above and you should be ready to connect to it.
|
name and cookie from the remote node and you should be ready to connect
|
||||||
Any code that you execute in the notebook now runs within the Phoenix
|
to it. Once connected, be careful: any code that you execute in the notebook
|
||||||
application you connected to.
|
now runs within the connected application. You are also limited on actions
|
||||||
|
you may perform. For example, you can't install dependencies (nor that would
|
||||||
|
be a good idea on a running system).
|
||||||
|
|
||||||
You may also [connect your local Livebook instance to a node running in
|
You may also [connect your local Livebook instance to a node running in
|
||||||
production depending on your platform](https://fly.io/docs/elixir/advanced-guides/connect-livebook-to-your-app/).
|
production depending on your platform](https://fly.io/docs/elixir/advanced-guides/connect-livebook-to-your-app/).
|
||||||
Once connected, Livebook can run any code within your production nodes
|
|
||||||
(similar to a remote shell) which can be useful to debug and run checks
|
|
||||||
on live systems.
|
|
||||||
|
|
||||||
Attached nodes can't install new dependencies on a attached runtime
|
|
||||||
and, in general, we recommend it only for debugging of external system.
|
|
||||||
|
|
||||||
<!-- livebook:{"break_markdown":true} -->
|
<!-- livebook:{"break_markdown":true} -->
|
||||||
|
|
||||||
|
@ -312,7 +310,7 @@ but in Erlang:
|
||||||
```
|
```
|
||||||
|
|
||||||
We are just beginning the Erlang integration and contributions to
|
We are just beginning the Erlang integration and contributions to
|
||||||
enrich the support are welcome.
|
further enrich it are welcome.
|
||||||
|
|
||||||
## Evaluation vs compilation
|
## Evaluation vs compilation
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue