added exit_on_exception configuration to worker

This commit is contained in:
Thomas Maddox 2013-05-23 10:03:19 -05:00
parent b815516b5f
commit e09a889f42
2 changed files with 11 additions and 4 deletions

View File

@ -6,7 +6,8 @@
"rabbit_port": 5672,
"rabbit_userid": "rabbit",
"rabbit_password": "rabbit",
"rabbit_virtual_host": "/"
"rabbit_virtual_host": "/",
"exit_on_exception": true
},
{
"name": "east_coast.prod.cell1",
@ -15,6 +16,7 @@
"rabbit_port": 5672,
"rabbit_userid": "rabbit",
"rabbit_password": "rabbit",
"rabbit_virtual_host": "/"
"rabbit_virtual_host": "/",
"exit_on_exception": false
}]
}

View File

@ -134,6 +134,11 @@ class NovaConsumer(kombu.mixins.ConsumerMixin):
def continue_running():
return True
def exit_or_sleep(exit=False):
if exit_on_exception:
sys.exit(1q)
else:
time.sleep(5)
def run(deployment_config):
name = deployment_config['name']
@ -170,11 +175,11 @@ def run(deployment_config):
LOG.error("!!!!Exception!!!!")
LOG.exception("name=%s, exception=%s. Reconnecting in 5s" %
(name, e))
time.sleep(5)
exit_or_sleep(deployment_config['exit_on_exception'])
LOG.debug("Completed processing on '%s'" % name)
except:
LOG.error("!!!!Exception!!!!")
e = sys.exc_info()[0]
msg = "Uncaught exception: deployment=%s, exception=%s. Retrying in 5s"
LOG.exception(msg % (name, e))
time.sleep(5)
exit_or_sleep(deployment_config['exit_on_exception'])