简体   繁体   English

在本地运行capistrano任务

[英]Run capistrano tasks locally

In my deploy.rb file I have a lot of tasks, one of which restarts the unicorn and some services. 在我的deploy.rb文件中,我有很多任务,其中之一重新启动独角兽和一些服务。 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. 我不想重复创建与rake任务相同的任务的代码。 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. 我想运行此任务,该任务已经存在并且已在deploy.rb文件中定义,但是我想在本地而不是远程执行。 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. 如果我理解正确,那么您将Capistrano任务作为部署的一部分在开发框中运行,它们将在服务器上执行。 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. 如果您在开发框中运行特定任务,例如bundle exec cap production unicorn:restart ,它将仅在服务器上执行该任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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