[fpc-pascal] Methods for autoupdating fpc programs?
Bo Berglund
bo.berglund at gmail.com
Mon Oct 5 00:23:48 CEST 2015
On Sun, 4 Oct 2015 12:37:29 +0100, Graeme Geldenhuys
<mailinglists at geldenhuys.co.uk> wrote:
>On 2015-10-03 19:30, Bo Berglund wrote:
>> But how could one exchange a running program on the pi from within
>> itself?
>
>On non-Windows platforms it is much easier, because you can normally
>replace a program on file, while it is running in memory. Windows
>doesn't allow that. Either way the solution is quite simple for most
>platforms.
>
>tiOPF's 'tiopf_apps' repository includes one such solution. In summary,
>the program checks for updates at startup - using HTTP, a database or
>whatever. If a update exists, launch the update program and quit. The
>update program will then fetch the update, and unpack the archive, then
>launch the original program and quit itself.
>
>For our desktop applications will added a message prompt to ask the
>end-user if the want to update, but for a automated system you obviously
>don't want that part. This solution has worked for us in production site
>for a good few years already.
>
Thanks for this info!
What I had in mind was to let the main program check the update state
when it it is run by cron (but only once a day, say first start after
midnight).
THe check would be done just before it exits (if it has nothing to do
or if it has finished a measurement run).
If it finds an update it will download it and apparently will be able
to replace its own executable before it exits. That is simplifying
things a lot compared to Windows.
Or it launches an updater program (separate application) and then
exits. Then the updater must be able to perform the update before the
next time cron calls a run. Could be tricky. There is a race
condition. But that would be there also if the main application
handles the update because we cannot say if cron starts it again while
it is busy measuring. Maybe I would have to think about this race a
bit, a lock file maybe....
Anyway the next time it will be the new version running.
Of course no user dialog, just silently update if needed.
--
Bo Berglund
Developer in Sweden
More information about the fpc-pascal
mailing list