Debugging processes in LiveBook

I’m trying to test out some supervision stuff with GenServers in LiveBook. I’ve easily managed to start the GenServers, which I assume are running under some master LiveBook supervisor.

My question is; how do you debug a process running in the background in LiveBook? As far as I can tell, there’s no way to access the console in LiveBook. So how can I debug this without console access?

I need to send it messages and normally I’d just have it print out some results to the console when it get the message and processes it.

You could probably start observer to see if your theory about the supervision tree is true.

You can start an iex shell iex --sname coolname --cookie monster -S mix and then attach your livebook session to that.

And, can’t you just send messages to your GenServer from livebook anyway? Throw some inspect/puts/Logger.debug and you should see that in livebook.

1 Like

I don’t really want to rely on being able to SSH in to open a new IEx session on the server running LiveBook, as the whole point of LiveBook is to run in the browser.

Maybe I could just have the process I’m testing send messages to the LiveBook process and then I could just receive them and read them. I’ll try that

Sorry, I don’t really understand what you’re doing. I assumed you were doing all this locally to learn about processes and supervision.

I’m just trying to use LiveBook to play around with things that require processes and supervision. But I can’t view the console when in LiveBook so it’s hard to debug those processes as there’s no way to just IO.inspect from a process in LiveBook to have it print out somewhere (as far as I can see).

Have you tried doing a call from a process? I think that should get printed out by Livebook (at least it does in NervesLivebook and I don’t think it is setting up anything special there).

1 Like

Wow that’s awesome! Thanks for the tip! I never would have thought to use Logger! It’s a bit odd that it runs in whatever cell was evaluated last but it works!

1 Like