lawik

lawik

Nerves Core Team

Installing plugins or extensions in a running application

I’ve been thinking about making an open source application in Elixir that would benefit from having extensibility from third parties. So the user of this application would download a compiled release, run it and decide “I want the last.fm scrobbler extension” and I want them to be able to bring in a bunch of modules by providing the files as a zip or whatever archive makes sense to the application.

This isn’t PHP, we can’t just drop them in a folder. But my first thinking is simply that the application compiles the new code and saves some config info to make sure it will be loaded on subsequent starts. It will not be part of the release but it will be part of the “installation”.

Does this make sense? Should I consider some alternate approaches?

I’d rather not make users compile the application source + their extensions beforehand as it would defeat many of the benefits of distributing ready-to-run binary releases.

Thoughts?

Most Liked

OvermindDL1

OvermindDL1

You can load extensions in real-time without issue. What I’ve always done is just add the compiled applications to the same library release (so they get loaded, or you can explicitly load from a path too, I’ve done that before as well), then just set the module entrypoint for it in a configuration (application environment), or if it’s a running system then just tell it to load it straight and it can register itself in and is immediately loaded and doing its work. :slight_smile:

As long as it’s in the load module path (which you can alter) and ‘something’ loads the entry module for the plugin (configuration files are great! or a database or whatever to get the names) then it all just works. You could even scan all beam files in the module paths for what implements a certain behaviour and load those as well (dynamic loading! I’ve done that before as well, though I like configs a bit more in ‘most’ cases, more control).

Just have to make sure the plugin is compiled with the same version as everything else, a simple build API fixes that up.

Or you can even load plugins as their own nodes that connect to the main system and register themselves in too, that’s fully under the plugin control then, no dynamic system needed. :slight_smile:

OvermindDL1

OvermindDL1

You can of course compile on demand, but you need to be sure to include the compiler libraries, and you wn’t have mix available unless you include that as well, which will generate how code can be generated as it won’t think it’s a full release then.

But yeah, compiled beam file’s are platform independent, but they are dependent on the OTP version (and to a lesser extent the Elixir version) that they are compiled with.

Last Post!

lawik

lawik

Nerves Core Team

Sounds like plenty of options at least :slight_smile:

Where Next?

Popular in Discussions Top

scouten
I’m looking for a host for the server part of a small (personal) side project that I’m working on. It’s currently written in Node.js and ...
New
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
lucaong
Hello Elixir and Nerves community, I have been working for a while on an open-source embedded key-value database for Elixir, that I call...
230 14403 124
New
Fl4m3Ph03n1x
Background A few days ago I was listening to The future of Elixir from Elixir Talks, with Dave Thomas (@pragdave ) and Brian Mitchell. I...
New

Other popular topics Top

stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New

We're in Beta

About us Mission Statement