<\/p>\n\r\n% mco service restart httpd --batch 10 --batch-sleep 2\r\nDiscovering hosts using the mongo method .... 26\r\n\r\n * [============================================================> ] 26 \/ 26\r\n\r\n.\r\n.\r\n.\r\n\r\nFinished processing 26 \/ 26 hosts in 6897.66 ms\r\n<\/pre>\n<\/code><\/p>\n
What you will see when running it on the CLI is that the progress bar will progress in groups of 10, pause 2 seconds and then do the next 10. In this case you could ^C at any time and only the machines in earlier batches and the 10 of the current batches will have restarted, future nodes would not yet be affected in any way.<\/p>\n
Under the hood MCollective detects that you want to do batching then force the system into Direct Addressing Mode and makes batches of requests. The requestid<\/em> stays the same throughout, auditing works, results work exactly as before and display behaviour does not change apart from progressing in steps.<\/p>\nUsing in code<\/H3>
\nNaturally you can also use this from your own code, here’s a simple script that does the same thing as above.<\/p>\n
<\/p>\n\r\n#!\/usr\/bin\/ruby\r\n\r\nrequire 'mcollective'\r\ninclude MCollective::RPC\r\n\r\nsvcs = rpcclient(\"service\")\r\n\r\nsvcs.batch_size = 10\r\nsvcs.batch_sleep_time = 2\r\n\r\nprintrpc svcs.restart(:service => \"httpd\")\r\n<\/pre>\n<\/code><\/p>\n
The key lines here are lines 8 and 9 that has the same behaviour as –batch<\/em> and –batch-sleep<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"This ia a post in a series of posts I am doing about MCollective 2.0 and later. We’ve discussed Direct Addressing Mode before and today I’ll show one of the new features this mode enables. Overview MCollective is very fast which is great usually. Sometimes though when you’re restarting webservers the speed and concurrency can […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","footnotes":""},"categories":[7],"tags":[85,78,106,13],"_links":{"self":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/2757"}],"collection":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/comments?post=2757"}],"version-history":[{"count":6,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/2757\/revisions"}],"predecessor-version":[{"id":2763,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/2757\/revisions\/2763"}],"wp:attachment":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/media?parent=2757"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/categories?post=2757"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/tags?post=2757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}