Chef 失败了我的资产:Opsworks 上的预编译步骤
Posted
技术标签:
【中文标题】Chef 失败了我的资产:Opsworks 上的预编译步骤【英文标题】:Chef fails my assets:precompile step on Opsworks 【发布时间】:2014-09-05 07:26:40 【问题描述】:将我的应用部署到 Amazon 的 Opsworks,我的资产预编译步骤经常失败。
主厨食谱如下所示:
node[:deploy].each do |application, deploy|
deploy deploy[:deploy_to] do
before_restart do
rails_env = deploy[:rails_env]
current_release = release_path
execute "rake assets:precompile" do
user deploy[:user]
cwd current_release
command "bundle exec rake assets:precompile"
environment "RAILS_ENV" => rails_env
end
end
end
end
...产生此错误:
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received ''
---- Begin output of bundle exec rake assets:precompile ----
STDOUT:
STDERR: I, [2014-07-15T02:05:30.399857 #12281] INFO -- : Writing <asset path>
...
...
...
---- End output of bundle exec rake assets:precompile ----
Ran bundle exec rake assets:precompile returned
编译步骤好像成功了,为什么Chef报错了?
【问题讨论】:
【参考方案1】:经过一番调查,看起来 Sprockets 正在将信息消息记录到标准错误中,Chef 将其解释为失败。
有 a pull request to change this behaviour,但它似乎与其中一位贡献者停滞不前...
因此,与此同时,我将 stderr 重定向到 stdin,如下所示:
node[:deploy].each do |application, deploy|
deploy deploy[:deploy_to] do
before_restart do
rails_env = deploy[:rails_env]
current_release = release_path
execute "rake assets:precompile" do
user deploy[:user]
cwd current_release
command "bundle exec rake assets:precompile 2>&1"
environment "RAILS_ENV" => rails_env
end
end
end
end
【讨论】:
以上是关于Chef 失败了我的资产:Opsworks 上的预编译步骤的主要内容,如果未能解决你的问题,请参考以下文章
Chef/OpsWorks:实例在新发布的 Windows 食谱版本上失败
安装 Postgresql 时 AWS Opsworks Chef 配方失败