Search code examples
nginxcapistranocapistrano3capifony

Why have I to delete current and releases to make Capistrano work on nginx?


I use Capistrano 3 and its plugin capistrano/symfony to deploy my Symfony application on a webserver. This server uses Nginx under Debian 8.

When I run cap prod deploy, the script works. I can see my new release on /var/www/myapp/releases. /var/www/myapp/current is a symbolic link that points to my latest release.

But when I access to my app, it stills serving the old release. I tried to restart nginx, but the issue stills the same.

The only "solution" I found is to delete /var/www/myapp/current and /var/www/myapp/releases before running the Capistrano deployment.

Have you got an idea of where it can come from ?


Solution

  • This is not nginx issue usually, but PHP caches (opcache, realpath, etc). So you can delete old folders manually (boring), write clear-all-php-caches script (results may vary) OR add php restart task into Capistrano 3 deploy process (my example for CentOS 7 with php-fpm):

    namespace :deploy do
    ...
      desc 'Restart application'
      task :restart do
        on roles(:app), in: :sequence, wait: 5 do
            sudo 'service php-fpm restart'
        end
      end
    ...
    end