Skip to content

Instantly share code, notes, and snippets.

@thmsmlr
Created January 14, 2024 21:59
Show Gist options
  • Save thmsmlr/ed85efa73dc8ee2857fc20c3814e62d5 to your computer and use it in GitHub Desktop.
Save thmsmlr/ed85efa73dc8ee2857fc20c3814e62d5 to your computer and use it in GitHub Desktop.
Kino Background Daemon
child_spec = Task.child_spec(fn ->
IO.puts("""
I am doing daemon things for my Livebook.
If I re-evaluate the cell, this task will be terminated and restart with the new version of the code.
If the task ever terminates, the Supervisor will automatically restart it.
Useful for running things in the background that don't need to directly interact with your notebook.
""")
Process.sleep(5000)
end)
Kino.start_child(%{child_spec | restart: :permanent})
Kino.nothing()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment