jalogut / magento2-deployer-plus

Tool based on deployer.org to perform zero downtime deployments of Magento 2 projects
GNU General Public License v3.0
200 stars 59 forks source link

OpCache Reset #30

Closed sprankhub closed 5 years ago

sprankhub commented 5 years ago

Since Deployer heavily relies on symlinks and symlinks are cached by the OpCache, a PHP reload or any other OpCache reset command is necessary during the deployment. Currently, this is done via a sudo command:

https://github.com/jalogut/magento2-deployer-plus/blob/66d1ee4dbc92e10e3ecc250598d12f9d961f110b/deploy.php.sample_2_2_5#L20

I suggest using the project CacheTool for it, because it does not rely on sudoer rights if I understand correctly.

What do you think?

stu177 commented 5 years ago

There is a method to allow a system user sudo rights for specific commands however this isn't ideal.

Any solution that works and doesn't require sudo would be a good amendment in my opinion.

jalogut commented 5 years ago

Hi @sprankhub

That is exactly the reason why this command is on the sample file and not inside the project task commands. The intention is just to provide an example. You should edit it with the command you wish. If you want to do it with the CacheTool, just install it as dependency in your project and edit the command to execute the CacheTool command.

In case that you want to use a sudo command, you can allow a user to run only specific commands as sudo. Exactly as @stu177 mentioned. You can check how to do it in the link below:

I hope this clarifies your issue

sprankhub commented 5 years ago

Thanks for the additional information! If I understand correctly, the CacheTool should work in any environment. Would you merge a pull request, if I provide a decent one?

jalogut commented 5 years ago

Hi, thanks for your proposal but I do not think that is needed. I would prefer not adding an additional dependency. I had some issues installing that tool in the past:

So for now I’d leave it like that. As I said, anyone can easily add the dependency on their projects and modify the command if they do not want to use sudo.

sprankhub commented 5 years ago

Hmm pity. If it worked correctly, we could add the OpCache clear command to the project task commands, which would be nice. However, if you do not want to add this, we can close this issue. Thanks for the fast feedback!

sprankhub commented 5 years ago

FYI I added deployer/recipes as a dependency now, required the cachetool file:

require 'vendor/deployer/recipes/recipe/cachetool.php';

defined when the OpCache clear should be done:

after('cache:clear', 'cachetool:clear:opcache');

and configured the cachetool parameter in my host definition:

->set('cachetool', '/var/run/php7.2-fpm-shop.tld.sock')

Seems to work.