-3

I am currently looking forward to work with a bare git repository in order to deploy on a production server, i have a "post-receive" hook who use git checkout to update the production folder. The application is a PHP Website.

In fact i'm wondering if it is absolutely safe to push on a production server with git while there is someone using the web-app, does git update the file in a transaction-like way by locking every update files or is he working files by files ? Is it possible that the user load the page and have the CSS of the old commit but the PHP of the new one ? (if he's very unlucky)

TL;DR : Is there any risk to push while people use the website ?

Sorry for my english ! Thanks for your help !

Fankohr
  • 1
  • 1
  • This isn't at all answerable in the general case, but it's safe to say that Git is not a deployment tool, and you shouldn't use it as one. – meager Oct 09 '18 at 14:44

2 Answers2

1

Git just copies in the files.

You probably need to manually restart your web server to pick up the changed php programs. Be carefull if you are using a mix of technologies some software will picked changed files immediately while others may wait for a restart.

In your case you need to check the php.ini file for opcache.revalidate_freq= and oapache.enable settings which control if and how often apache looks for changed source files.

For a production server it is probably safer to turn them off and restart the server to pick up changed files.

James Anderson
  • 26,221
  • 7
  • 45
  • 76
0

That depends entirely on what is using the files and if the files are open and if whatever has the files open will re-read them at some point.

On some systems, you can update the files in place, but they are ignored until the application and/or service is restarted.

On other systems, the change is picked up immediately.

On still other systems, the files are open and you can't overwrite them.

In short, this has little to do with git and a lot to do with what's using the files.

Also, you need to be aware of what happens between versions. If the fields changed between versions, you'll need to make sure you can handle cases where the page getting the form post is going to receive different data than it was expecting.

does git update the file in a transaction-like way by locking every update files

AFAIK, git works on a file-by-file basis and there's no rollback if something fails on one file or another.

Terry Carmen
  • 3,328
  • 1
  • 12
  • 26