在下面的代码中,我创build了一个服务,我希望在部署它所依赖的文件之后才能启动,并在这些文件发生更改时重新启动它。 这个非常基本的配方不能像我所期望的那样工作:
supervisor_service "test-service" do command "/bin/cat" autostart false action :enable end cookbook_file "/tmp/test.txt" do source "test.txt" notifies :restart, 'supervisor_service[test-service]' end
在运行结束时,厨师客户端只logging:
- supervisor_service [test-service]动作重启(最新)
…服务不运行。 手动sudo supervisorctl restart test-service工作正常。
就我而言,重新启动操作是资源更改状态的请求(启用 – >启动),向厨师expression这一点的正确方法是什么?
编辑 :我认为这将是值得添加使用:立即修饰符导致行动正确执行。 然而,在实践中,我有多个文件,可能会触发重新启动,我需要所有这些在重新启动之前更新(完全是行为:延迟是为了提供)。
我正在使用厨师10.14.4,我也遇到了同样的问题。 你使用的是什么版本?
通知确实出现在日志文件中,就好像它即将在supervisor_service提供程序上运行:restart操作一样:
INFO: cookbook_file[/tmp/test.txt] sending restart action to supervisor_service[test-service] (delayed) INFO: Processing supervisor_service[test-service] action restart (temp::default line 16)
但是,我们只是得到:
INFO: Chef Run complete in 14.302624 seconds
同时,我能做的最好的工作是:
supervisor_service "test-service" do command "/bin/cat" autostart false action :enable end execute "restart test-service" do command "supervisorctl restart test-service" user "root" action :nothing end cookbook_file "/tmp/test.txt" do source "test.txt" notifies :run, "execute[restart test-service]" end
这本质上是完全相同的代码,而不是运行。
由于这个工作正常,但是通知supervisor_service提供者没有,所以只能假设在这个文件中存在一个在监督者食谱(v0.4.0)中的错误。