简体   繁体   中英

Run capistrano tasks locally

In my deploy.rb file I have a lot of tasks, one of which restarts the unicorn and some services. For example:

namespace :deploy do
  task :restart do
    invoke 'unicorn:restart' # using capistrano3-unicorn gem
    invoke 'some_service:restart'
    ...
  end
end

Now I need to run the same task locally through console on production server. I don't want to duplicate my code creating the same task as a rake task. I want to run this task, which is already exists and defined in the deploy.rb file, but I want to do it locally, not remotely. Is it possible ?

If I understand correctly, you have your Capistrano tasks which you run from your dev box as part of your deployment, and they execute on the server. You now want to run a specific command on the server, and you are logged into the server.

I'm not sure how to do it that way, but I'd suggest an alternative which might get you what you want. If you, on your dev box, run a specific task such as bundle exec cap production unicorn:restart , it will execute just that task on the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM