Forum Moderators: phranque
Just to hear what you guys do to avoid causing bad surfing to your clients during code updates. IŽve noticed that when the ftp program is overwritting the online script with the new copy we have just coded up (improvements, corrections etc, you know), if some user tries to use the online file, heŽll crash, as the file is incomplete or zero-lenght.
I wonder if there is some way to avoid that... Is there? Or we just have to hang out 'till 5:00 am to do this kind of maintenance?
Thanks a lot
phoenix_fly
My file uploader now uploads all files (not just CGIs, also HTML tempates etc) to temporary names -- eg my-script.php-temp.
Then an "enabling" cgi whizzes through the website folders deleting and renaming files, and, when needed, setting file permissions.
Total "exposure" time for any CGI to be unavailable is a fraction of a second.
(Actually, it's slightly more complicated than that as the uploader uploads a sort of "make" file to tell the enabler the order in which to do things. That way we do things usually in the "right" order -- eg the new index.php doesn't get renamed until all new pages it refers to are enabled. But that's additional protection over and above the immediate problem you have)
Those are pretty good ideas, thanks a lot! I think physics moving-directories may be interessting when you have modifications in many scripts, and VictorŽs enabling-script when you want to target precisely the last changes, having the choice of setting the order of the modifications.
But now it comes to me that maybe I could blend both, uploading only the modified scripts to /cgi-bin2 and having the enabling-script to go seek there for the replacements to the old mates at /cgi-bin. This way I donŽt have to worry about renaming the new scripts to temporary names (as they wont share the same directory as the old ones).
Victor said about a cgi script, but isnŽt this simpler to do in shell scripting? The point is that I am not familiar to it, so I think IŽll go look into that...
Thanks a lot pals!
Take care
phoenix_fly
#!/bin/sh
mv cgi-bin cgi-bin-old
mv cgi-bin2 cgi-bin
I bet it would be so fast that it wouldn't be necessary to write a more complicated script... worth trying anyway.
Is your box at home a *nix box? If so you could write a push-button update script using rsync and ssh keys.
IŽll post the shell script I created to do the magic weŽve been talking. Place it in the temporary directory you want to act as a pivot to the update.
#!/bin/bash
# I called the file update.sh
for file in *cgi # only cgi files. And not the update.sh!
do
mv "$file" ../cgi-bin/"$file" # change cgi-bin to your official scripts directory
chmod 755 ../cgi-bin/"$file"
done
echo "Update: concluded"
exit 0
I believe that in fact the renaming-directory technique can be faster than this moving-file one. But, as I am wired via dial-up to the net, to make a all-script upload is too time-consuming. So I prefer to upload only the scripts where IŽve made modifications. And, anyway, the server performs this move like a lightning flash.
Hope you like the code!
phoenix_fly