Stop Monit entries one at a time
`monit stop all` fails for Monit 5.16 when the combine list of
entry names is longer than 1kb.
@@ -17,11 +17,22 @@ module TerminateHelper
`rm -f /etc/nginx/sites-enabled/appscale-*.conf`
`rm -f /etc/haproxy/sites-enabled/*.cfg`
`service nginx reload`
- while system("monit summary | grep Running > /dev/null") do
- # Stop and then remove the service we configured with monit.
- `monit stop all`
+
puts "Waiting for monit to stop services ..."
- Kernel.sleep(10)
+ loop do
+ monit_output = `monit summary`
+ all_stopped = true
+ monit_output.each_line do |line|
+ # Leave cron-related entries alone.
+ next if line.start_with?('cron')
+ next if line.start_with?('System')
+ next unless line.include?('Running')
+ all_stopped = false
+ entry = line.split[1][1..-2]
+ `monit stop #{entry} 2>&1`
+ sleep(0.5)
+ end
+ break if all_stopped
end
`rm -f /etc/monit/conf.d/appscale*.cfg`
