Casey DeLorme

modernizer

I only found one alternative, and they put a ton of effort into supporting binary delta updates, which I think are a waste of time and code.

As usual, I decided to write my own. In roughly a weekend I was able to create a tool that downloads a version file, compares versions, downloads and replaces the binary in a cross-platform compatible way, and launches the new executable while retaining the default file descriptors.

Windows has two minor glitches that required a bit of extra cleanup work. First it does not offer Exec, so the process id changes, but it somehow inherits the same streams (stdin/stdout/stderr all continue to work correctly). Second in order to eliminate the previous binary a rename and cleanup process is required since windows locks the binary file during execution (I assume due to mmap calls?).

While it isn’t a perfect solution for all use-cases, it works great and is damn small (less than 200 lines of code).

For complex situations where you need to cleanup the existing runtime, or want to carry over an open network connection (eg. keep a service active) then you probably want something more complex and tailor-made.

written on 2017-04-13