mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-03-09 21:37:42 +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.
|
||||
|
||||
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
|
||||
notebook runtime like this:
|
||||
other, they need to have the same cookie. The cookie serves as a very simple
|
||||
authentication mechanism. We can read the cookie of our current notebook runtime
|
||||
like this:
|
||||
|
||||
```elixir
|
||||
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,
|
||||
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.
|
||||
To work around this, let's simply copy the cell that define the
|
||||
`Portal.Door` module into the other notebook and execute it. Now we should
|
||||
be able to shoot a door in the other node:
|
||||
To work around this, you should simply copy the cell that define the
|
||||
`Portal.Door` module from this notebook into the other notebook and
|
||||
execute it. Now we should be able to shoot a door in the other node:
|
||||
|
||||
<!-- livebook:{"force_markdown":true} -->
|
||||
|
||||
|
|
|
@ -24,27 +24,27 @@ alias VegaLite, as: Vl
|
|||
|
||||
## Connecting to a remote node
|
||||
|
||||
This time we will connect to a running node manually instead of
|
||||
injecting Livebook there, because we may not want to run `Mix.install/1`
|
||||
inside it. This will also give you a better idea of how you can
|
||||
inspect a remote node in general.
|
||||
While Livebook can run a notebook directly inside a remote node,
|
||||
this time we will connect to a running node manually to minimize
|
||||
the impact in the remote system. This will also give you a better
|
||||
idea of how you can inspect a remote node in general.
|
||||
|
||||
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
|
||||
automatically starts each notebook as a remote node.
|
||||
you can do so by opening up [a new notebook](/explore/notebooks/new),
|
||||
since Livebook automatically starts each notebook as a remote node.
|
||||
|
||||
In practice, you may want to start an existing Elixir system,
|
||||
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
|
||||
[`mix release`](https://hexdocs.pm/mix/Mix.Tasks.Release.html).
|
||||
|
||||
Once you start a new notebook, you can find the node name
|
||||
and cookie by running this:
|
||||
Once you start a new notebook, you can find its node name and
|
||||
cookie by running the following inside an Elixir cell:
|
||||
|
||||
<!-- livebook:{"force_markdown":true} -->
|
||||
|
||||
|
@ -53,12 +53,15 @@ IO.puts node()
|
|||
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":"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
|
||||
node =
|
||||
IO.gets("Node: ")
|
||||
|
|
Loading…
Reference in a new issue