0

What is the proper protocol for enabling a custom built extension during production mode?

When I run php bin/magento setup:upgrade I get the following error:

The directory "/chroot/home/af3d0522/45913c4122.nxcli.net/magento/generated/code/Magento" cannot be deleted Warning!rmdir(/chroot/home/af3d0522/45913c4122.nxcli.net/magento/generated/code/Magento): Directory not empty

Should I be deleting the code within generated/code and then running the above command so that Magento acknowledges the extension? I'm going to re-try tonight to enable my own custom extension along with a few others that are disabled. If anyone can provide a run-down on best practices I would really appreciate it. It's a M2 2.3.4 store.

3 Answers 3

0

In production mode we always needs to run bin/magento setup:di:compile after setup upgrade this will compile all the code and write the generated folder. This is why the setup:upgrade is trying to erase that folder.

If you have that error it probably means you are wrong permission on the folder or the user you are running the commands with have the wrong access.

If you are using capistrano to deploy here is a rake file that will fix your problem

namespace :magento do
  namespace :setup do
    desc 'Custom rights on application'
    task :permissions do
      on release_roles :all do
        within release_path do
          execute :find, release_path, "-type d ! -perm 755 -exec chmod 755 {} +"
          execute :find, release_path, "-type f ! -perm 644 -exec chmod 644 {} +"
        end
      end
    end
  end
end

Otherwise you probably need to fix that in your jenkins file but can't tell you where.

EDIT : Any case each time you will want to make a modification in production mode you should set your magento in maintenance mode first. And if the process isn't automatic with capistrano or jenkins then i will say it should be a good idea to make a database backup first.

0

If chmod won't help then this might be caused by cron that is re-generating classes in the /generated directory. Kill running crons before deploy.

As Claims mentioned earlier, you should consider automating the deployment process. Machines are better than we are at repetitive and boring tasks.

BTW, You can control module status in the config.php:

'Magento_Analytics' => 0,

or remove it from the composer.json:

    "replace": {
        "amzn/amazon-pay-and-login-magento-2-module": "*",

and then enable all modules during deployment:

bin/magento module:enable --all
0

If you are in Production and want to Enable/Disable The Extension, then just simply put the site in maintainance mode and then run the upgrade, compile and deploy commands and aftr it disable the maintance mode.

bin/magento maintenance:enable

// Do your work - enable/disable the extension, upgrade, compile, deploy

bin/magento maintenance:disable 

bin/magento maintenance:status

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.