厨师客户取消通知延迟 [英] chef client cancel notifies delayed

查看:62
本文介绍了厨师客户取消通知延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法取消通知以重新启动设置为延迟的服务。例如,这是一个配置更改代码块:

I am wondering if there is a way to cancel a notification to restart a service that was set to delayed. For example, here is a configuration change code block:

template "/etc/myapp/myconfig.conf" do
    source "myconfig.conf.erb"
    mode 0600
    notifies :restart, "service[myapp]", :delayed
end

但是在我的菜谱末尾,我有一些逻辑,如果满足某些条件,实际上将禁用该应用程序。这可以正常工作,但是在禁用之后(在Chef运行结束时),延迟的重新启动请求启动并重新启动过程。我想知道是否有一种方法可以告诉厨师,如果该服务被禁用,则取消该服务的所有重新启动请求。有想法吗?

But then at the end of my recipe, I have some logic that will actually disable the app if certain conditions are met. This works fine, but then just after the disable (at the end of the chef run), the delayed restart request kicks in and restarts the process. I'm wondering if there is a way to tell chef to cancel all restart requests for the service if it get's disabled. Thoughts?

推荐答案

可以做到,但这并不漂亮。您需要进入[ run_context ] [1]并持有[ delayed_notification_collection ] [2 ]。然后,您可以删除通知。但是请注意,这是对厨师内部的深深m惑,因此不鼓励使用。

It can be done, but it is not pretty. You would need to reach into the [run_context][1] and get a hold of the [delayed_notification_collection][2]. You could then remove the notification. But be aware, this is mucking pretty deeply into the internals of chef, which is highly discouraged.

看看这本食谱

take a look at this "cookbook" for an example. It's only been tested to the extent that the test-kitchen tests exercise it.

这篇关于厨师客户取消通知延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆