mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-03-10 05:49:32 +08:00
Copy edits to distributed .livemd
This commit is contained in:
parent
c1d462620b
commit
ea7bba11cd
2 changed files with 19 additions and 15 deletions
|
@ -684,8 +684,9 @@ Node.list(:hidden)
|
||||||
Much better! We see one node, which is the Livebook server itself.
|
Much better! We see one node, which is the Livebook server itself.
|
||||||
|
|
||||||
Now there is one last piece of the puzzle: in order for nodes to connect to each
|
Now there is one last piece of the puzzle: in order for nodes to connect to each
|
||||||
other, they need to have the same cookie. We can read the cookie of our current
|
other, they need to have the same cookie. The cookie serves as a very simple
|
||||||
notebook runtime like this:
|
authentication mechanism. We can read the cookie of our current notebook runtime
|
||||||
|
like this:
|
||||||
|
|
||||||
```elixir
|
```elixir
|
||||||
Node.get_cookie()
|
Node.get_cookie()
|
||||||
|
@ -756,9 +757,9 @@ Portal code has been defined in this notebook but it is not available
|
||||||
in the other notebook. If we were working on an actual Elixir project,
|
in the other notebook. If we were working on an actual Elixir project,
|
||||||
this issue wouldn't exist, because we would start multiple nodes on top
|
this issue wouldn't exist, because we would start multiple nodes on top
|
||||||
of the same codebase with the same modules, but we can't do so here.
|
of the same codebase with the same modules, but we can't do so here.
|
||||||
To work around this, let's simply copy the cell that define the
|
To work around this, you should simply copy the cell that define the
|
||||||
`Portal.Door` module into the other notebook and execute it. Now we should
|
`Portal.Door` module from this notebook into the other notebook and
|
||||||
be able to shoot a door in the other node:
|
execute it. Now we should be able to shoot a door in the other node:
|
||||||
|
|
||||||
<!-- livebook:{"force_markdown":true} -->
|
<!-- livebook:{"force_markdown":true} -->
|
||||||
|
|
||||||
|
|
|
@ -24,27 +24,27 @@ alias VegaLite, as: Vl
|
||||||
|
|
||||||
## Connecting to a remote node
|
## Connecting to a remote node
|
||||||
|
|
||||||
This time we will connect to a running node manually instead of
|
While Livebook can run a notebook directly inside a remote node,
|
||||||
injecting Livebook there, because we may not want to run `Mix.install/1`
|
this time we will connect to a running node manually to minimize
|
||||||
inside it. This will also give you a better idea of how you can
|
the impact in the remote system. This will also give you a better
|
||||||
inspect a remote node in general.
|
idea of how you can inspect a remote node in general.
|
||||||
|
|
||||||
The first thing we need is a separate Elixir node. For this example,
|
The first thing we need is a separate Elixir node. For this example,
|
||||||
you can do so by opening up [a new notebook](/explore/notebooks/new), since Livebook
|
you can do so by opening up [a new notebook](/explore/notebooks/new),
|
||||||
automatically starts each notebook as a remote node.
|
since Livebook automatically starts each notebook as a remote node.
|
||||||
|
|
||||||
In practice, you may want to start an existing Elixir system,
|
In practice, you may want to start an existing Elixir system,
|
||||||
such as by running the following in your production app:
|
such as by running the following in your production app:
|
||||||
|
|
||||||
```
|
```
|
||||||
elixir --sname my_app -S mix TASK
|
elixir --name my_app@IP -S mix TASK
|
||||||
```
|
```
|
||||||
|
|
||||||
Or by connecting to a production assembled via
|
Or by connecting to a production assembled via
|
||||||
[`mix release`](https://hexdocs.pm/mix/Mix.Tasks.Release.html).
|
[`mix release`](https://hexdocs.pm/mix/Mix.Tasks.Release.html).
|
||||||
|
|
||||||
Once you start a new notebook, you can find the node name
|
Once you start a new notebook, you can find its node name and
|
||||||
and cookie by running this:
|
cookie by running the following inside an Elixir cell:
|
||||||
|
|
||||||
<!-- livebook:{"force_markdown":true} -->
|
<!-- livebook:{"force_markdown":true} -->
|
||||||
|
|
||||||
|
@ -53,12 +53,15 @@ IO.puts node()
|
||||||
IO.puts Node.get_cookie()
|
IO.puts Node.get_cookie()
|
||||||
```
|
```
|
||||||
|
|
||||||
Now, let's paste these in the inputs below:
|
Now, paste these in the inputs below:
|
||||||
|
|
||||||
<!-- livebook:{"livebook_object":"cell_input","name":"Node","type":"text","value":""} -->
|
<!-- livebook:{"livebook_object":"cell_input","name":"Node","type":"text","value":""} -->
|
||||||
|
|
||||||
<!-- livebook:{"livebook_object":"cell_input","name":"Cookie","type":"text","value":""} -->
|
<!-- livebook:{"livebook_object":"cell_input","name":"Cookie","type":"text","value":""} -->
|
||||||
|
|
||||||
|
And now execute the code cell below, which will read the inputs,
|
||||||
|
configure the cookie, and connect to the other notebook:
|
||||||
|
|
||||||
```elixir
|
```elixir
|
||||||
node =
|
node =
|
||||||
IO.gets("Node: ")
|
IO.gets("Node: ")
|
||||||
|
|
Loading…
Reference in a new issue