magento-hackathon / magento-composer-installer

Composer installer for Magento modules
210 stars 154 forks source link

Invalid symlinks created when using Capistrano deployment tool and magento-root-dir #140

Closed gplanchat closed 9 years ago

gplanchat commented 9 years ago

This is more an informative ticket than a bug report while using Capistrano. The issue appears in a specific context when using the magento-root-dir option with some ./directory/ value instead of directory/.

Capistrano is a deployment tool in which it is possible to integrate composer. Capistrano creates a directory hierarchy to make deployments as smooth as possible and enables rollback by keeping old versions of sites on the server.

Capistrano creates this file structure :

/var/www/
        + current/ -> symlink to a releases/xxxxx directory
        + releases/
            + <timestamp1>/ -> production snapshot #1 of the application
            + <timestamp2>/ -> production snapshot #2 of the application
            + <timestamp3>/ -> production snapshot #3 of the application
            + ...
        + shared/ -> common files to each releases

While using Capistrano deployment tools, and as said above, with a ./prefix to the magento directory name, the symlinks are not correctly set. The install script seems to create symlinks as if it uses the realpath of the directory /var/www/releases/<timestampx>/, but the webserver does access the files from /var/www/current/ and thus will not react the same way with relative symlinks..

To illustrate, the symlink index.php points to ../../vendor/connect20/Mage_Downloader/index.php, which brings the webserver to search for a file named /var/vendor/connect20/Mage_Downloader/index.php

roman204 commented 9 years ago

if you are on php5.5 with Zend opCode Cache than the opCode Cache is responsible to that behaviour

Flyingmana commented 9 years ago

thats an interesting case, I will try to reproduce this in a Integration test when I have time. I will comment here if I have further questions or a result

gplanchat commented 9 years ago

Yes, I am on 5.5 with OPCache activated

roman204 commented 9 years ago

so OPCache will Cache the target fo the script ... clear the OPCache after deploy:finished in capistrano

after "deploy:finished", "your_namespace:clear_opcache"

desc "clear opcache"
task :clear_opcache do 
    on roles(:app) do
        within release_path do
                  execute :php, "-r", "opcache_reset();"
        end
    end
end