Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capistrano 3 recipe #23

Open
janosrusiczki opened this issue May 28, 2014 · 2 comments
Open

Capistrano 3 recipe #23

janosrusiczki opened this issue May 28, 2014 · 2 comments

Comments

@janosrusiczki
Copy link

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
Copy link
Author

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.

@lassebunk
Copy link
Owner

Thanks. We will update this in the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants