mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 18:08:42 -05:00
Check for dead threads and restart them
This commit is contained in:
parent
8aab996666
commit
e8881d601c
1 changed files with 14 additions and 2 deletions
|
|
@ -31,6 +31,9 @@ end
|
||||||
# Connect to Redis
|
# Connect to Redis
|
||||||
$redis = Redis.new
|
$redis = Redis.new
|
||||||
|
|
||||||
|
# Our thread-tracker object
|
||||||
|
$threads = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check the state of a VM
|
# Check the state of a VM
|
||||||
|
|
@ -171,9 +174,9 @@ def destroy_vm vm, pool
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_pool pool
|
def check_pool pool
|
||||||
puts "Starting new worker thread for pool '#{pool['name']}'"
|
$logger.log('d', "[*] [#{pool['name']}] starting worker thread")
|
||||||
|
|
||||||
Thread.new {
|
$threads[pool['name']] = Thread.new {
|
||||||
loop do
|
loop do
|
||||||
# INVENTORY
|
# INVENTORY
|
||||||
inventory = {}
|
inventory = {}
|
||||||
|
|
@ -251,6 +254,8 @@ end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$logger.log('d', "starting vmware-host-pooler")
|
||||||
|
|
||||||
pools.each do |pool|
|
pools.each do |pool|
|
||||||
check_pool(pool)
|
check_pool(pool)
|
||||||
end
|
end
|
||||||
|
|
@ -258,6 +263,13 @@ end
|
||||||
|
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
|
pools.each do |pool|
|
||||||
|
if (! $threads[pool['name']].alive?)
|
||||||
|
$logger.log('d', "[!] [#{pool['name']}] worker thread died, restarting")
|
||||||
|
check_pool(pool)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
sleep(1)
|
sleep(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue