views:

37

answers:

3

Hi,

Let's say you have a big web app with large visits, but you don't want your app to crash & you don't want people to see the php or mysql errors that happens during replacing files using FTP, How to avoid that? How to just execute the old version of file until the replacing is done?

Thanks

+2  A: 

you can follow at least one of this 2 rules:

  1. to use accelerators (like APC) with turned off mtime checking. so until you clear cache manually - old versions will be used from memory
  2. to use virtualhost symlinked to directory with your project: let's examine you store yout project at /home/project/www. and /home/project/public_html is your real webroot and symlinked to www. so - create /home/project/www2, checkout files there, setup and do whatever you want. after this - just change symlink.
zerkms
A: 

Deploy your app into the temporary directory. Then after you done, just rename the original app directory to app.old and the directory where you deployed your files into app

Note this should work okay in Unix environments. Also this will only work if all of the above directories are on the same file systems. In rare case users might see 404 error if they happen to access the app after your renamed the original app into .old and before you renamed temp dir into the original app directory.

Vlad
+1  A: 

I use git to upload my changes to a staging website on the same server, after testing I then push it to the production website. None of the files are changed until they are all received. On the plus side, it only sends the changes compressed, so I don't even have to send an entire file.

The staging area isn't required. I work with a lot of servers and sometimes some of the specific configurations on that server (mostly just find that an extension isn't installed)/

I'm sure you can do the same with another version control system. You need to be careful though. The tutorial I linked specifically stores the git information OUTSIDE the document root. Otherwise someone can just clone all the source code for your website.

If you like SVN, the .svn being in every directory can be a little annoying. Make sure that people can't download what they shouldn't be able to.

AlReece45
i don't believe that pushing operation is atomic. despite the fact that the operation of push is atomic itself - it doesn't mean that the copying from some temporary directory to destination is atomic. so the trouble of inconsistent sources is still here.
zerkms
@zerkms pushing doesn't automatically update the repository. it just sends the information. Only after the push is complete does a hook execute a checkout using the new information. You can cancel in the middle of a push and the changes will not appear. Usually when git encounters an issue in the checkout (like permissions). It backs out and leaves your sources in a consistent state.
AlReece45