To get hot-swap for code is tricky to get right, if possible at all.
It depends on the changeset and the running application too.
Issues:
- old vars may litter namespaces and cause subtle conflicts, bugs
- redefinition of multiple vars is not atomic
There may be old vars in a namespace that will not be there if you restart the application, however will interfere if you just redefine some of the functions and keep the app running without restart.
The other issue is atomicity: redefining multiple functions i.e. changing multiple vars is not atomic. If you change functions in one or more namespace that code in some other namespace depends on, reloading the namespaces with the new code is not atomic.
Generally, you are better off either
- having a proxy hold the requests until your app restarts
- spinning up a new app instance parallel to the "old version" and use a proxy to switch from the new version after the new version is ready to process requests