def redeploy_to_ec2(name, host_string, logfile=None): """ Deploy latest docker to EC2 """ if logfile is None: logfile = open(os.devnull, 'w') try: print '%s: Redeploying to EC2' % timestamp() sys.stdout = logfile with settings(host_string=host_string, key_filename=name + '.pem', connection_attempts=3): fabfile.copy_files() fabfile.deploy() finally: sys.stdout.close() sys.stdout = sys.__stdout__
def cycle(hostname, username, logname, keyfile, last_position): while True: print 'Last position for host ' + hostname + ': ', last_position fabfile.deploy(hostname, username, logname, last_position, keyfile) last_position = fabfile.getlast(hostname, username, logname, last_position, keyfile) time.sleep(period)
from fabfile import deploy deploy()