【问题标题】:NoMethodError: undefined method `execute' or 'run' capistrano 3NoMethodError:未定义的方法“执行”或“运行”capistrano 3
【发布时间】:2014-12-26 07:59:22
【问题描述】:

我试图在我的 capistrano 脚本中部署后调用 php 脚本,如果我尝试执行,则会收到以下错误

NoMethodError: undefined method `execute' for main:Object

如果我尝试运行,我会收到以下错误

NoMethodError: undefined method `run' for main:Object

下面是我正在使用的脚本

namespace :deploy do
        task :run_sql do
            run  "php -q /home/mydir/public_html/index.php argumen1 argument2 argument3 argument4"  
        end
end
after :deploy, "deploy:run_sql"

任何建议我做错了什么?

PS:一旦我的代码被部署并且这个 php 文件在我要部署到的服务器上,我将在部署后执行这个。

【问题讨论】:

  • 你能显示完整的脚本及其位置吗?
  • 您没有回答执行问题 - 看起来该方法由于某种原因不存在。我认为跑步是一条红鲱鱼。

标签: ruby ruby-on-rails-3 capistrano capistrano3


【解决方案1】:

您的语法适用于 2.x 版本。请参考这里:undefined method `run' for main:Object

namespace :deploy do
  on roles :all do
    execute :php, "-q /home/mydir/public_html/index.php argumen1 argument2 argument3 argument4"
  end
end

【讨论】:

  • Ariahnt - 你错过了 on roles(:all) 块 - 当你拥有它时它就会起作用。
猜你喜欢
  • 2020-10-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-24
  • 2015-05-19
  • 1970-01-01
相关资源
最近更新 更多