I have rabbitmq installed on one of my servers, and I log into it and issue the command :
"service rabbitmq stop"
Which is followed by:
"service rabbitmq start"
Now sometimes it so happens that the service will not stop/start for a long time. So I will need to abort the service (by sending a keyboard interrupt ^C) and run the command again.
I want to replicate the same using fabric. I read the docs, and it said there is an option called command_timeout. Not much documentation is available about it. Here is my code snippet that I am trying to use:
def restartRabbitMQ():
flag1 = True
flag2 = True
with settings(command_timeout=15, warn_only=True):
while flag1:
result = sudo("service rabbitmq-server stop")
if result.failed:
continue
flag1 = False
while flag2:
result = sudo("service rabbitmq-server start")
if result.failed:
continue
flag2 = False
However, this command will be stuck till unless rabbitmq starts/stops itself or there is an error starting/stopping rabbitmq. command_timeout seems to have no effect whatsoever.