-
Notifications
You must be signed in to change notification settings - Fork 48
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
Command mapping #56
Comments
Mmh 🤔 Setting up the mapping after However, as mentioned before, setting up the mapping in the top scope in # config/deploy/staging.rb
set :deploy_to, '/var/www/app-staging' # config/deploy/production.rb
set :deploy_to, '/var/www/app-production' When I set up the command mapping in set :application, 'app'
SSHKit.config.command_map[:composer] = "php #{shared_path.join('composer.phar')}" Printing the mapping in a task (say
It should be:
When I define the command mapping in the separate stage files (after the final, stage-specific I'll probably find a cleaner solution though and post it here when I find it 🙂 Then maybe updating the instructions here could be worth it for people who run into a similar issue. Cheers |
Okay, so the following works for all my use-cases (running composer tasks during deploy but also separately): # config/deploy.rb
stages.each do |stage|
after stage, :map_commands do
SSHKit.config.command_map[:composer] = "php #{shared_path.join('composer.phar')}"
end
end This defers the command mapping until all the stage variables, in particular Should this be mentioned in the description for the I am also wondering whether this would be relevant for the general Capistrano FAQs or some place similar @capistrano? In hindsight it makes a lot of sense, but initially I didn't think too much about the order in which the general deploy config, stage config and command mappings are initialized. I guess others might run into this too. Thank you all for these super-helpful tools 🙇 |
An (more involved) alternative could also be for Capistrano to provide a complete wrapper around the SSHKit command map, which might look like the following: # Define a command mapping with lazy initialization
command :composer, -> { "php #{shared_path.join('composer.phar'}" }
# Read command mappings
commands[:composer]
# => 'php /var/www/…' Not sure about how exactly this could be tied into SSHKit though or whether that would just remain on the Capistrano layer: task :example do
on roles(:all) do
execute commands[:composer], '--version'
# or (as before)
execute :composer, '--version'
end
end |
Hey there, thanks for creating this gem 🙇
I've run into an issue when following the instructions in the README as the
shared_path
is not necessarily set correctly when you define the command mapping in the top-level scope.Instead, what worked for me was to defer the mapping until after
deploy:starting
, where we can be sure theshared_path
is initialized to the correct value:Maybe it'd make sense to update the README and
composer:install_executable
task description?The text was updated successfully, but these errors were encountered: