Making an optionally headless Phoenix app

I want to make a freestanding binary, e.g. ./awesome. When you start this app it runs in the background and does a bunch of OTP things. In production, I just want it to do the OTP things. When in debug mode or on the developer’s workstation, I’d like to have a Phoenix app sitting on top of this binary so that I can administer the daemon with a UI.

Is there a way to:
a) Make this all a single self-executing, freestanding binary
b) Make it so that we only have the extra space, overhead, memory usage of Phoenix if we’re in dev mode (I’m okay with having 2 separate binaries, etc)

Thanks for any advice!

Another thought is to maybe have the Phoenix app be one binary and the daemon be another, and when the phoenix app starts, it joins the cluster made by the first app? This way the extra size and overhead of the web app is purely opt-in. Not sure if this is idiomatic or typical design, though.

Second thought is to just cut two releases - one that has the phoenix app in it and the other that doesn’t, though that’s really the part I don’t know how to do.

I think it’s Umbrella for. Just make two apps lib and lib_web, make two kinds of releases (both and only lib). Is what you are looking? You may check here: Configuration and releases - The Elixir programming language

P.S: Ah, you actually don’t need second release, it’s for dev purpose, so just one then.

Would it make sense for 3 apps in the umbrella: the shared otp app, the binary/cli, and then the web app?

Yeah, you can have them as many as you need, in any variations. About your question - i think it’s pretty general to split it that way. Except binary/cli part, what does it mean? Will you use your cli under development? If yes, it could be placed inside otp, i think. If not, then web will be depended only from otp, and cli will be too. And inside release just add cli, which will fetch and compile inside release all dependencies including otp(mark it as an umbrella dependency inside cli mix)


I’ve been looking at distillery and still can’t find anything in the docs about releasing a standalone binary, just tarballs. Is there a good resource on releasing standalone binaries?

There is no “standalone” binary in Erlang. You can “hack it” with tools like Bakeware but it is “just” self extracting archive.