[fpc-pascal] Configuration file handling
Marco van de Voort
marcov at stack.nl
Sat Feb 16 11:05:07 CET 2013
In our previous episode, Mark Morgan Lloyd said:
> If multiple, related, programs running on unix (Linux, Solaris etc.)
> refer to the same configuration file accessed via a TIniFile, is there
> any recommended "good practice" to ensure that they don't try to update
> it simultaneously?
>
> In the case that I'm thinking of, I don't anticipate e.g. multiple
> logins trying to write setup information at the same time
That sounds like the domain of of filelocking (fp)Flock.
> The more risky case is if there are e.g. multiple daemons or apps trying
> to save state when a UPS signals imminent shutdown.
Have all systems regularly write local files in something that is not
cleared on startup. (e.g. change clearing /tmp to a monthly cronjob
instead of startup)
On startup check for crash (local file exists) and if the
local file is newer than the server, copy and continue starting up.
More information about the fpc-pascal
mailing list