Find file
Fetching contributors…
Cannot retrieve contributors at this time
68 lines (54 sloc) 2 KB
# Copyright (C) 2011, 2012 9apps B.V.
# This file is part of Redis for AWS.
# Redis for AWS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# Redis for AWS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with Redis for AWS. If not, see <>.
import os, sys, redis
from urllib2 import urlopen
from cluster import Cluster
from host import Host
from route53 import Route53Zone
from ec2 import EC2
from events import Events
# your amazon keys
key = os.environ['EC2_KEY_ID']
access = os.environ['EC2_SECRET_KEY']
# what is the domain to work with
name = os.environ['REDIS_NAME'].strip()
zone_name = os.environ['HOSTED_ZONE_NAME'].rstrip('.')
zone_id = os.environ['HOSTED_ZONE_ID']
# the name (and identity) of the cluster (the master)
cluster = "{0}.{1}".format(name, zone_name)
# get/create the cluster environment
cluster = Cluster(key, access, cluster)
events = Events(key, access,
host = Host(, events)
node = host.get_node()
endpoint = host.get_endpoint()
component = os.path.basename(sys.argv[0])
def log(message, logging='info'):
events.log(node, component, message, logging)
r = redis.StrictRedis(host='localhost', port=6379)
if __name__ == '__main__':
log('get Redis INFO', 'info')
info =
log('get the link_status', 'info')
if 'master_link_status' in info:
log('determine if our master is up', 'info')
if info['master_link_status'] == "up":
log('master is up: touch the slave', 'info')
os.system('/bin/touch /var/run/redis/slave')
except Exception as e:
log('no redis yet?', 'info')