added exit_on_exception configuration to worker
This commit is contained in:
parent
b815516b5f
commit
e09a889f42
@ -6,7 +6,8 @@
|
|||||||
"rabbit_port": 5672,
|
"rabbit_port": 5672,
|
||||||
"rabbit_userid": "rabbit",
|
"rabbit_userid": "rabbit",
|
||||||
"rabbit_password": "rabbit",
|
"rabbit_password": "rabbit",
|
||||||
"rabbit_virtual_host": "/"
|
"rabbit_virtual_host": "/",
|
||||||
|
"exit_on_exception": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "east_coast.prod.cell1",
|
"name": "east_coast.prod.cell1",
|
||||||
@ -15,6 +16,7 @@
|
|||||||
"rabbit_port": 5672,
|
"rabbit_port": 5672,
|
||||||
"rabbit_userid": "rabbit",
|
"rabbit_userid": "rabbit",
|
||||||
"rabbit_password": "rabbit",
|
"rabbit_password": "rabbit",
|
||||||
"rabbit_virtual_host": "/"
|
"rabbit_virtual_host": "/",
|
||||||
|
"exit_on_exception": false
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
@ -134,6 +134,11 @@ class NovaConsumer(kombu.mixins.ConsumerMixin):
|
|||||||
def continue_running():
|
def continue_running():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def exit_or_sleep(exit=False):
|
||||||
|
if exit_on_exception:
|
||||||
|
sys.exit(1q)
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
def run(deployment_config):
|
def run(deployment_config):
|
||||||
name = deployment_config['name']
|
name = deployment_config['name']
|
||||||
@ -170,11 +175,11 @@ def run(deployment_config):
|
|||||||
LOG.error("!!!!Exception!!!!")
|
LOG.error("!!!!Exception!!!!")
|
||||||
LOG.exception("name=%s, exception=%s. Reconnecting in 5s" %
|
LOG.exception("name=%s, exception=%s. Reconnecting in 5s" %
|
||||||
(name, e))
|
(name, e))
|
||||||
time.sleep(5)
|
exit_or_sleep(deployment_config['exit_on_exception'])
|
||||||
LOG.debug("Completed processing on '%s'" % name)
|
LOG.debug("Completed processing on '%s'" % name)
|
||||||
except:
|
except:
|
||||||
LOG.error("!!!!Exception!!!!")
|
LOG.error("!!!!Exception!!!!")
|
||||||
e = sys.exc_info()[0]
|
e = sys.exc_info()[0]
|
||||||
msg = "Uncaught exception: deployment=%s, exception=%s. Retrying in 5s"
|
msg = "Uncaught exception: deployment=%s, exception=%s. Retrying in 5s"
|
||||||
LOG.exception(msg % (name, e))
|
LOG.exception(msg % (name, e))
|
||||||
time.sleep(5)
|
exit_or_sleep(deployment_config['exit_on_exception'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user