def rabbit_work_function(ch, method, properties, body):
try:
# check the message body to get the needed order
app_json = loads(body)
# if it's blank stop containers and kill worker-manger container
if len(app_json) == 0:
stop_containers(app_json)
print "got a blank massage from rabbit - likely app wasn't created in nebula API yet, dropping container"
os._exit(2)
# elif it's stopped stop containers
elif app_json["command"] == "stop":
stop_containers(app_json)
# if it's start start containers
elif app_json["command"] == "start":
start_containers(app_json, False, registry_auth_user, registry_auth_password, registry_host)
# if it's roll rolling restart containers
elif app_json["command"] == "roll":
roll_containers(app_json, registry_auth_user, registry_auth_password, registry_host)
# elif restart containers
else:
restart_containers(app_json, registry_auth_user, registry_auth_password, registry_host)
# ack message
rabbit_ack(ch, method)
except pika.exceptions.ConnectionClosed:
print "lost rabbitmq connection mid transfer - dropping container to be on the safe side"
os._exit(2)
评论列表
文章目录