Live reloading without phoenix / liveview?

I just want to save a file and auto recompile, nothing more, no restarting, no plugs. We have an application that is just normal elixir without phoenix or live view or external assets. This may be answered somewhere, but I cannot find it anywhere because there are so many posts about live reloading not working in the contexts of these other projects.

We’ve been using for years a program we wrote ourselves, rl | Hex which is notable by how incredibly bad it is. If you have multiple nodes up clustered they both recompile and fight each other. Sometimes I wake up in the morning and my cpu is at 100% because it is just spinning for no good reason. Rarely it just stops working entirely until I restart it.

I tried phoenix_code_reloader, but looking at it, I can’t see where it actually recompiles anything and indeed it doesn’t seem to do anything without additional configuration involving endpoints that don’t exist in my project.

Lettuce seems to provide this capability.

1 Like

Yeah Phoenix.CodeReloader is a little hard to follow. The actual compilation happens on line 307 of Phoenix.CodeReloader.Server (and is tied to phoenix configuration):

When I want to recompile my code on any changes I use exsync (I’m also a maintainer):

One great benefit of exsync is that if you use path: dependencies then they’ll automatically be recompiled for you with no additional configuration needed (with phoenix you need to manually set :reloadable_apps).

3 Likes

Lettuce looks a bit primitive, but exsync actually may be a real improvement over what I use. I will give it a spin soon and see how well it works.

1 Like

We are using remixed_remix | Hex and it’s working quite well.

1 Like

You can also take a look at BigBrother — BigBrother v0.1.0. I did it a while ago by extracting the recompilation part from phoenix.

If you need support for this specific library, feel free to contact me.

3 Likes