3 ms·
If you're so inclined, I'd also like to hear about the hot code reloading information you've found.
by tdenkinger 15y ago
If you're so inclined, I'd also like to hear about the hot code reloading information you've found.
- irahul 15y agoI didn't find much information concerning ruby. Basically, the approach to hot code reloading is: 1. Find a way to attach to a running process. Either leave a socket open, as done in twisted manhole; or directly attach to running process. 2. Once you are connected, if you get a repl in the same address space, you can redefine methods, classes etc. See the example in the github README where he redefines a method. 3. Redefining running code is generally considered a bad idea. The usefulness of a repl to a running process is generally the analysis - you can monitor memory usage etc without changing anything. 4. When you do change things, it's mostly small changes viz. log calls to a particular method. Dummy example: class Foo alias_method :orig_handler, :handler def handler log_request orig_handler end end 5. The way erlang does it is it automatically reloads if the physical file changes. It's a bit hard to implement in Python/Ruby because it isn't supported out of the box, and figuring out the module dependency isn't reliable(if file a changes, how many files were depending on it?). The general approach is to restart the server. 6. But regardless, the remote repl gives you analysis and selective reloading which is also useful.