in reply to Sanely modifying running code

I don't know what the requirements are, but here are some random thoughts...

Would it make more sense to have a babysitter app running that launches the working app, checks for updates, signals the old app to stop accepting new work (and terminate, if that's appropriate), and launches a new updated app?

Given your suggested approach, what are the implications if there's a bug in the update?

Can the new functionality be returned as a data structure? If the file is updated, run it to get the new data structure. Run some tests against it, then replace the old data structure with the new. On the other hand, if the tests fail, keep the old data structure. (Replacing symbol table entries in a module is easy -- replacing other stuff is problematic.)

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^2: Sanely modifying running code
by Limbic~Region (Chancellor) on Mar 14, 2006 at 17:04 UTC
    QM,
    The requirements are that I can't drop connected users while still changing the code. I could make a proxy application which doesn't really do anything except persist the connection. It would have the ability to switch which backend process it interacts with. Then it is a simple matter of bringing up a new instance of the process and signaling the proxy app to switch. This is a really neat idea and I will try it out eventually.

    As far as problems with the current implementation - things could go boom if there is a bug in the update. There are ways of removing compile time bugs by making everything code refs and then eval'ing them before switching but that won't fix run-time bugs.

    Cheers - L~R

      There are ways of removing compile time bugs by making everything code refs and then eval'ing them before switching but that won't fix run-time bugs.
      I was hinting at running tests on the new stuff before it's accepted by the proxy process and supercedes the old stuff. Something like
      if (check_for_new_stuff($new_stuff_location)) { my $new_stuff = do $new_stuff_location; if (run_time_tests($new_stuff)) { $old_stuff = $new_stuff; } }

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of