How to add and install deps without stopping phoenix server (hex package)

Hi friends, I have created a simple code to install deps in runtime. You can see it in this video.

It can help my CMS to have an installer, like Joomla, WordPress! But losing the app state will be updated is my problem.
The question is when admin user want to update a library which has state (it has been installed and activated before), I need to stop and unload it, hence I am going to lose the dep state, it is my responsibility to save external developer dep, or I need to create structure to send him a request and he/she saves the state.

I need your suggestion, thank you in advance.

Code:


Update

I see some Erlang source code, when they want to update a gen server, they freeze it and after update resume.

But how can freeze all the state which are created by a specific app I want to update and the states maybe dynamic supervisors

Why I do stop, because I can not use Application.load(app) when the app exists before, so I need to unload it, for example update timex to new version, it needs to be stop and after that it lets me to update and load again

This section code: