Background
I have project that I started with escript.build
. It worked really well at first, but now the project has matured and I actually need to do a release for it. The main idea here is to create a release so the project can run on multiple OS, like window and unix for example.
Issue
However, I am really lost when it comes to this. My project is an umbrela app, and with a CLI for an interface. Right now I am under the impression I would have to:
- change the project so it has GenServers
- Get rid of the CLI interface in favor of Phoenix Live or something alike so the users can interact with the app
- Do a release (not sure how)
I honesty feel overwhelmed, I am not sure if I am thinking right. The project is open sourced if any one has interest:
Questions
- what is the simplest step I can take to move my app from an escript to mix release?
- Can I keep the CLI interface or do I need to replace it with something more complex?
2 Likes
Here I am going to share my experience and my findings.
Turns out my initial plan was correct.
- Supervision trees and GenServers
To turn an escript build into a release you need to have an application that sticks around with a Supervision tree (even if said supervision tree is empty).
So in my case, the simplest step (which in on itself was rather hard) was to add a decent Supervision tree to my project. I created a Supervisor (Manager
) that would take care of its dependencies and restarted them when needed (in this case I only had one that needed this, a GenServer called AuctionHouse
).
- Application
With this out of the way, it was time for the second step. To turn my CLI
module into an application, that would supervise Manager
. By application I mean the typical project with a MyApp.Application
file in it.
- Be free!
With this structure done it was time for the mix release
code to be added to mix.exs
. Once this was done I had a fully functional release for windows and linux.
No Phoenix Live nor any of that was needed.