in reply to Re^2: Other Script Processes
in thread Other Script Processes

If I'm not mistaken, rename is atomic on unix, so instead of copying your new file over the old one, move it over.

For example, upload the new index.cgi as index.cgi.new, then issue mv index.cgi.new index.cgi.

Replies are listed 'Best First'.
Re^4: Other Script Processes
by powerhouse (Friar) on Nov 17, 2007 at 02:41 UTC
    Ok, so If I am updating the core file, vars.conf which has all that magic in it, then name it vars2.conf then just use unix to overwrite it and it should not interfere with users loading pages?

    Is that correct?
    thx,
    Richard

      I believe so. Even if some processes have the file is open (say the perl parser), it's not a problem since the actual file on disk isn't changed. The perl accessing the old version of the file will continue to access the old version (which will get deleted once all file handles to it are closed). New perl instances will see the new file and open and parse that one.

      I'm assuming you're only reading from this file.

      If the core file is "vars.conf", you want to copy that to some other name (like "new-vars.conf"), alter the contents of that copy as needed, and when you are sure it is ready for use, just:
      mv new-vars.conf vars.conf
      (as a shell command) or just rename "new-vars.conf", "vars.conf" (as a step in a perl script -- same thing). That way, no one will ever get a partial (or partially edited) version of the file. Assuming the file is read only once per client process, there won't be any inconsistencies from the client's perspective.