厨师独立通知
Chef stand alone notify
使用 Chef,我想在调用另一个资源的上下文之外使用通知功能。
这是我一直在做的变通方法,但我想知道是否有更简洁的方法来做到这一点:
execute 'restart myapp' do
command '/srv/www/myapp/shared/scripts/myapp restart'
action :nothing
end
# Code here does configuration and dependencies restart notifications
execute 'echo "Restarting myapp"' do
notifies :run, 'execute[restart myapp]'
end
这里的关键是我需要 execute[restart myapp]
到 运行 之后所有其他潜在的通知来自前面的食谱。
你可以这样做节省一毫秒
ruby_block 'noop' do
block { }
notifies :run, 'execute[cleanup]'
end
但总体上要警惕这种设计。延迟通知是一个一招的小马,没有办法获得 "later than all deferreds" 例如。考虑使用自定义资源并将您需要的行为更紧密地限定在单个操作方法中。
使用 Chef,我想在调用另一个资源的上下文之外使用通知功能。
这是我一直在做的变通方法,但我想知道是否有更简洁的方法来做到这一点:
execute 'restart myapp' do
command '/srv/www/myapp/shared/scripts/myapp restart'
action :nothing
end
# Code here does configuration and dependencies restart notifications
execute 'echo "Restarting myapp"' do
notifies :run, 'execute[restart myapp]'
end
这里的关键是我需要 execute[restart myapp]
到 运行 之后所有其他潜在的通知来自前面的食谱。
你可以这样做节省一毫秒
ruby_block 'noop' do
block { }
notifies :run, 'execute[cleanup]'
end
但总体上要警惕这种设计。延迟通知是一个一招的小马,没有办法获得 "later than all deferreds" 例如。考虑使用自定义资源并将您需要的行为更紧密地限定在单个操作方法中。