mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-09 21:16:26 +08:00
Update demo
This commit is contained in:
parent
a006ce34f9
commit
24035602f2
1 changed files with 8 additions and 4 deletions
|
@ -24,7 +24,10 @@ defmodule Demo.Server do
|
||||||
@impl true
|
@impl true
|
||||||
def init(_) do
|
def init(_) do
|
||||||
Process.flag(:trap_exit, true)
|
Process.flag(:trap_exit, true)
|
||||||
{:ok, server_pid} = ElixirKit.start()
|
|
||||||
|
{:ok, pid} = ElixirKit.start()
|
||||||
|
ref = Process.monitor(pid)
|
||||||
|
|
||||||
log("init")
|
log("init")
|
||||||
|
|
||||||
Task.start(fn ->
|
Task.start(fn ->
|
||||||
|
@ -36,7 +39,7 @@ defmodule Demo.Server do
|
||||||
System.stop()
|
System.stop()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
{:ok, %{server_pid: server_pid}}
|
{:ok, %{ref: ref}}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
@ -46,8 +49,9 @@ defmodule Demo.Server do
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def handle_info({:EXIT, pid, :shutdown}, state) when pid == state.server_pid do
|
def handle_info({:DOWN, ref, :process, _, :shutdown}, state) when ref == state.ref do
|
||||||
{:noreply, state}
|
System.stop()
|
||||||
|
{:stop, :shutdown, state}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|
Loading…
Add table
Reference in a new issue