Skip to content

Instantly share code, notes, and snippets.

@dvl
Last active September 9, 2015 17:23
Show Gist options
  • Save dvl/e9d0d0d325d6616e2009 to your computer and use it in GitHub Desktop.
Save dvl/e9d0d0d325d6616e2009 to your computer and use it in GitHub Desktop.
# -*- 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