0

我完全不了解安装未安装 init.d 文件的服务的工作流程。以下是我安装主管的秘诀。同样在boostrap的错误下方。我有 init.d 和配置文件作为模板。那么,我该如何调整逻辑让厨师工作呢?

ec2-175-41-185-174.ap-southeast-1.compute.amazonaws.com [Thu, 17 May
2012 22:18:02 +0000] ERROR: Running exception handlers
ec2-175-41-185-174.ap-southeast-1.compute.amazonaws.com [Thu, 17 May
2012 22:18:02 +0000] FATAL: Saving node information to
/var/chef/cache/failed-run-data.json
ec2-175-41-185-174.ap-southeast-1.compute.amazonaws.com [Thu, 17 May
2012 22:18:02 +0000] ERROR: Exception handlers complete
ec2-175-41-185-174.ap-southeast-1.compute.amazonaws.com [Thu, 17 May
2012 22:18:02 +0000] FATAL: Stacktrace dumped to
/var/chef/cache/chef-stacktrace.out
ec2-175-41-185-174.ap-southeast-1.compute.amazonaws.com [Thu, 17 May
2012 22:18:02 +0000] FATAL: Errno::ENOENT: service[supervisord]
(supervisor::default line 23) had an error: Errno::ENOENT: No such
file or directory - /etc/init.d/supervisord restart



easy_install_package "supervisor" do
 action :install
end

template "/etc/supervisord.conf" do
 path "/etc/supervisord.conf"
 source "supervisord.conf.erb"
 owner "root"
 group "root"
 mode "0600"
end

template "/etc/init.d/supervisord" do
 path "/etc/init.d/supervisord"
 source "supervisord.erb"
 owner "root"
 group "root"
 mode "0755"
 #notifies :start, "service[supervisord]", :immediately
end

service "supervisord" do
 supports :restart => true, :start => true, :stop => true, :reload => true
 action [ :enable]
 subscribes :start, resources(:template =>
"/etc/init.d/supervisord"), :immediately
end
4

1 回答 1

0

我相信您的问题是由于您在通知订阅属性中使用:immediately所致。

当您使用:immediately时,通知会立即运行,这在某些情况下是有意义的,但在这种情况下,由于 Chef 执行执行的方式,您正在通知或订阅的资源可能还不存在。

默认情况下,通知是: delayed的,这意味着它们排队等待触发并在 Chef 运行结束时执行。然后可以将它们传递到您要通知的服务和其他资源。

对于上面的示例,我将修改如下:

template "/etc/supervisord.conf" do
 path "/etc/supervisord.conf"
 source "supervisord.conf.erb"
 owner "root"
 group "root"
 mode "0600"
 notifies :reload, "service[supervisord]", :delayed
end

template "/etc/init.d/supervisord" do
 path "/etc/init.d/supervisord"
 source "supervisord.erb"
 owner "root"
 group "root"
 mode "0755"
 notifies :reload, "service[supervisord]", :delayed
end

service "supervisord" do
 supports :restart => true, :start => true, :stop => true, :reload => true
 action :enable
end

上面的代码执行以下操作:

  • 创建 supervisord 配置文件,然后在 Chef 运行结束时通知 supervisord 重新加载
  • 创建 supervisord init.d 脚本,然后在 Chef 运行结束时通知 supervisord 重新加载
  • 声明 supervisord 服务资源,支持重启、启动、停止和重新加载,并在其中任何一个运行后启用它

有关 Chef如何执行运行列表和运行列表中的食谱的更多信息,请参阅The Chef Run或更早版本,但在某些方面仍然更清楚Chef Run 的剖析。

于 2013-02-10T19:25:58.790 回答