ruby - How to break or stop ruby_block running in loop cause of "subscribes"
问题描述
Hi have a recipe where I am trying to check if a service is running and accessible.
So I have a "ruby_block" which checks if service is running if not it "notifies" to "execute" block to start it, once execute block starts the service I need to again check if it running by calling "ruby_block" using "subscribes" But when service fails to start "ruby_block" goes in unstoppable loop.
Below is recipe which describes the workflow
ruby_block 'check_if_Service_running' do
block do
# ...some logic to check service
# generates a return code 301 if successful or any other value if fails and
# assign it to an attribute check eg. value = return_code
end
notifies :run, 'execute['start_service']', :immediately
subscribes :run,'execute[Start_Service]', :immediately
end
execute 'Start_Service' do
#...code to start the service
action :nothing
not_if { value == 301 }
end
So in this case when Services fails to start even after execute block, ruby_block keeps on running and notify "execute" block and so on
note: when service starts successfully it does show expected behavior
But some times when service does not start it goes in loop
Please help me here to stop "ruby_block" being going in loop cause of subscribes for more than 2 times and stop everything (loop) if service felt to start
Any help will be appreciated!
解决方案
相反,创建一个自定义资源,您希望对事物进行比 DSL 提供的更明确的控制。
推荐阅读
- reactjs - 延迟加载和对象数组而不是组件?
- python - 可变 Numpy 重塑
- python - 如何理解python中的导入?
- google-cloud-platform - 尝试将项目迁移到新的 Google Cloud 组织,但如何让我的组织可选择作为迁移选项?
- asp.net - 如何使用带有 .cshtml 文件的函数更改文本?
- php - 正确形成多个 foreach 语句
- apache-camel - 如何使用标头值动态写入 Camel 中的不同文件夹?
- javascript - 无法获取嵌套数组对象中的对象值
- java - 在 Spring Boot Secured Web Application (Https) 中使用 Google Adsense Management Api
- python - 如何正确处理将 html 输入值获取到 Django 中的视图和 url 模式?