dynamic_sitemaps icon indicating copy to clipboard operation
dynamic_sitemaps copied to clipboard

Capistrano 3 recipe

Open janosrusiczki opened this issue 11 years ago • 2 comments

Note: This is a copy paste from my question posted to Stack Overflow.

I'm trying to "translate" the Capistrano recipe to deploy dynamic_sitemaps to work with Capistrano 3.

The snippet suggested in the readme looks like this:

after "deploy:update_code", "sitemaps:create_symlink"

namespace :sitemaps do
  task :create_symlink, roles: :app do
    run "mkdir -p #{shared_path}/sitemaps"
    run "rm -rf #{release_path}/public/sitemaps"
    run "ln -s #{shared_path}/sitemaps #{release_path}/public/sitemaps"
  end
end

But this doesn't work with Capistrano 3. I pasted this code into config/deploy.rb and the first error I got was: Don't know how to build task 'sitemaps:create_symlink'`.

I read somewhere that in Capistrano 3 the namespaces have to be defined before the calls so I reversed the order of the blocks, defining the namespace first and having the after call last. I got NoMethodError: undefined method map' for :roles:Symbol.

So I rewrote the namespace block to:

namespace :sitemaps do
  task :create_symlink do 
    on roles(:web) do
      run "mkdir -p #{shared_path}/sitemaps"
      run "rm -rf #{release_path}/public/sitemaps"
      run "ln -s #{shared_path}/sitemaps #{release_path}/public/sitemaps"
    end
  end
end

And now I'm getting Don't know how to build task 'deploy:update_code' and I'm at loss.

janosrusiczki avatar May 28 '14 09:05 janosrusiczki

While I couldn't solve precisely the issue I posted above, the solution is actually very simple. If using Capistrano 3 just add public/sitemaps to your :linked_dirs setting as such:

set :linked_dirs, %w{bin log tmp vendor/bundle public/system public/sitemaps}

This will create a symbolic link between #{release_path}/public/sitemaps and #{shared_path}/public/sitemap creating the latter if needed.

janosrusiczki avatar May 28 '14 19:05 janosrusiczki

Thanks. We will update this in the readme.

lassebunk avatar Jun 20 '14 10:06 lassebunk