Here is the context of my problem : we have managed servers (Hetzner) and are trying to implement a zero downtime deployment with symlinks. Here is what we do on each push : we deploy the new code in a new directory, change the symlink of the document root to point to that new directory, keep the last 4 releases and delete the older one, clear opcache by calling a php file via curl (opcache_reset() in it). The problem is random : sometimes it works fine and sometimes we are experiencing 500 HTTP errors and some "cannot redeclare" errors and it seems it's trying to serve 2 releases in the same time as you can see down here : enter image description here
The thing is we are doing the same thing for another app, but this one running on Symfony and we have no problem at all.
We are running on Apache, PHP 8.1 with OPCache activated and the following php config : enter image description here
I tried to change the opcache config (validate_timestamps 0/1, use_cwd, etc) and it did'nt resolve my problem.
I also tried to add a composer clear-cache command after resetting opcache, didn't work either.
I tried to change +FollowSymlinks to +SymLinksIfOwnerMatch in .htacces file, didn't work.
The strange thing is that it can either work for 10 back to back push and then doesn't work, it's completely random.
If any of you have an idea or solution, that would be great ! Thanks.