Last active
September 9, 2015 17:23
-
-
Save dvl/e9d0d0d325d6616e2009 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from fabric.api import ( | |
env, | |
serial, | |
settings, | |
sudo, | |
task, | |
warn_only, | |
) | |
env.hosts = [ | |
'localhost', | |
] | |
env.user = 'ec2-user' | |
env.key_filename = '/home/andre/.ssh/aws.pem' | |
env.start_command = 'service wowza start' | |
env.stop_command = 'service wowza stop' | |
env.max_retries = 10 | |
class WowzaException(Exception): | |
pass | |
@task | |
@serial | |
def restart_wowza(): | |
with warn_only(): | |
sudo(env.stop_command) | |
with settings(abort_exception=WowzaException): | |
for i in range(env.max_retries): | |
try: | |
sudo(env.start_command) | |
except WowzaException: | |
continue | |
else: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment