3 ms·
This has been submitted before, but it didn't get much attention. I stumbled onto it while researching hot code reloading in ruby.
by irahul 15y ago
This has been submitted before, but it didn't get much attention.
I stumbled onto it while researching hot code reloading in ruby.
- petercooper 15y agoYeah, 2.5 years old :-) But luckily HN is not time sensitive like many sites, a lot of old stuff hits the front page. With the hot code reloading features in some JVMs now, it'd be interesting to see if there's any case for it in JRuby one day.
- irahul 15y agoI found hijack on your blog: http://www.rubyinside.com/hijack-get-a-live-irb-prompt-for-any-existing-ruby-process-2232.html http://www.rubyinside.com/hijack-get-a-live-irb-prompt-for-a... This ranks higher than the github repo while searching for "ruby attach running process." hnsearch showed the same article being submitted about 2 years ago, with not much interest showed. I was a bit surprised. I was searching for HN thread as I was expecting some useful discussion, but found none. I assumed this is the kind of topic which would interest HN crowd, but looks like that isn't the case.
- petercooper 15y agoHN is a funny beast. Unless it's something affecting a YC company or an obviously big story, it's pot luck as to whether something will take off or not. Often the same story or same blog post will hit it big after multiple 1 point postings. (I did the first HN post about TechCrunch's new design, 1 point.. later one went big :-) I've even done the first post of items on the 37signals blog and Mixergy that have sat at 1. All depends who's browsing the 'new' page in that 30 minute window!)
- tdenkinger 15y agoIf 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.