How to set a timeout in deploy_revision provider?

有些话、适合烂在心里 提交于 2019-12-10 15:53:42

问题


I found a situation when chef had generated Chef::Exceptions::CommandTimeout exception in git clone command. Sometimes the time of git clone could be more than 10 minutes. How to set the timeout value for such situations in chef recipe?


回答1:


Timeout for the git provider seems to be fixed now.

Checkout the code at: https://github.com/opscode/chef/blob/master/lib/chef/provider/git.rb#L292

So for the git resource you can just add the timeout attribute, i.e.:

git /var/www do
  repository <githubrepo>
  action :sync
  user www-data
  group www-data
  timeout 1200
end



回答2:


There is no simple way of changing timeout, I mean by passing some attributes. You will have to overwrite run_options method in git provider. Check out When monkey patching a method, can you call the overridden method from the new implementation? for different possibilities.




回答3:


same issue here. thanks for the hint. was able to write the monkey patch like so:

https://gist.github.com/mikesmullin/5660466



来源:https://stackoverflow.com/questions/14557118/how-to-set-a-timeout-in-deploy-revision-provider

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!