【问题标题】:How to execute bundle command from Capistrano deploy script如何从 Capistrano 部署脚本执行捆绑命令
【发布时间】:2014-09-07 09:40:57
【问题描述】:

我想在部署后重新启动瘦 Web 服务器。为此,我在config/deploy.rb 中有以下代码:

namespace :deploy do
desc 'Restart application...'
  task :restart do
    on roles(:app) do
      within "#{current_path}" do
        execute "bundle exec thin -C /etc/thin/app.yml restart"
      end
    end
  end
(...)

所以我想在当前路径文件夹中执行bundle exec thin -C /etc/thin/app.yml restart命令。

这会引发错误:

SSHKit::Runner::ExecuteError: 在主机上执行时出现异常 ...: bundle exec thin -C /etc/thin/reboot.yml restart exit status: 127

/EDIT 首先显示另一个错误,因为早期代码中存在语法错误。用户RAJ 在下面的回答中发现了此错误

此任务出现同样的错误:

task :restart do
on roles(:app) do
  within "#{current_path}" do
    execute :bundle, "thin -C /etc/thin/reboot.yml restart"
  end
end

如何从部署脚本运行捆绑包?

【问题讨论】:

    标签: ruby-on-rails ruby deployment capistrano


    【解决方案1】:

    如错误消息所示,您缺少within 的块。

    试试这个:

    within "#{current_path}" do
      execute "bundle exec thin -C /etc/thin/app.yml restart"
    end
    

    而不是

    within "#{current_path}"
            execute "bundle exec thin -C /etc/thin/app.yml restart"
    

    【讨论】:

    • 啊,当然可以。但是,现在我又得到了SSHKit::Runner::ExecuteError: Exception while executing on host ...: bundle exec thin -C /etc/thin/reboot.yml restart exit status: 127。我已经更新了问题。
    • @user2609980 你不应该像现在这样编辑你的问题。尝试重置您的问题,然后通过提及您的编辑在问题底部进一步添加编辑..
    • 我认为如果我这样做,问题会变得太混乱。
    • 是的,您是对的,因为您已经得到了原始问题的答案,您应该关闭此问题并添加新问题。如果你愿意,可以加我。我会尽力帮助你
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多