Normally the changes are made with the system paused, without executions. Because often an update can also modify the database, authentication rules, etc. So in these more critical cases, it is more recommended to interrupt all hits.
Alternatively, for minor cases where you do not necessarily need to overturn any connections, you could create a mirror of that system within the same server. So I would always do the updates on the "mirror" that is "sleeping".
DocumentRoot Technique
Example, in Apache the original site is in the directory
/www/site/
The mirror, that is, an exact copy of all these files from the original is in another folder
/www/mirror/site/
Suppose at this point the site is running with 200 concurrent connections and you do not have loadbalance or anything. All you have is one server. So you have to deal with what you have.
You need to update 200 files, but without interrupting anything or causing data corruption.
So what you could do is update the files in the mirror directory
/www/mirror/site/
When complete, go to Apache and change the DocumentRoot
to the location of the mirror
<VirtualHost 127.0.0.1:80>
#DocumentRoot "/www/site/"
DocumentRoot "/www/mirror/site/"
</VirtualHost>
Save the change and give a reload or restart.
The site will now be running under the system with the updated files.
This is just one of several techniques and has points to observe as possible conflict with some other system that is depending on the original location of DocumentRoot
. There may also be some loss of cache data. But they are usually small losses that recover in the first executions. Just be aware of dependencies that can cause conflicts, but in an environment in normal conditions, have no problems.
Note that there will also be a loss of connections due to restarting Apache.
DirectoryIndex Technique
Another less invasive mode that follows the same logic of document root swapping is to do this by changing only the htaccess
. But this will depend on how the system files are structured. If it is well organized you can do the same scheme mentioned above, but using only htaccess
, without restarting Apache.
Logic is simple, typically the system only has the index.php
file in the public folder. You can have a second file, let's call it foo.php
.
In htaccess
, just change DirectoryIndex
to that other foo.php
file.
The foo.php
file includes mirror directory files.
All you need to do is follow the same logic as the virtualhost
example, except that instead of moving directly to Apache, you would only change DiretoryIndex
. A simple htaccess
upload would already be swapping from one directory to another.
And so you follow in turn. In the next update, you make changes to the directory that is "sleeping".
obs: In the examples I used Apache and PHP because they are more popular but can be applied in any other environment.