问题
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