how to hot reload my rpyc server after modification?
ZKeeer opened this issue · 1 comments
ZKeeer commented
I want to reload the new code after modifying the server code without interrupting my service. How can I do this?
Thank you very much for your reply~
comrumino commented
You could attempt "hot reload" by versioning your exposed procedure calls, follow the expand-contract philosophy, use importlib.reload to pull in the latest code, and then replace references to the old objects with the new objects---the most important attribute to update would be the reference stored under rpyc.utils.Server.service
.
Some things to consider:
- "Yeah, yeah, but your scientists were so preoccupied with whether or not they could that they didn't stop to think if they should." - Jurassic Park
- Existing connections would still reference the old objects/code with hot reloading
- Hot reloading is more complex for services that have mutable types than for services which only transmit immutable types. Mutable types would result in netrefs which would still reference old objects in the connection cache.
- Depending on your requirements, best practices like blue/green deployments (e.g., using haproxy) might be a better design choice
Feel free to reopen if you have follow up questions.