示例#1
0
    def _provision(self, *args, **kwargs):
        # generate redis config
        with hide('stdout', 'warnings'):
            password = generate_password()
            sudo('cp -f {0} {1}'.format(self._default_conf, self._conf))
            # edit config
            sudo("sed -i 's/bind.*/bind 0.0.0.0/g' {0}".format(
                self._conf))
            sudo("sed -i 's/port.*/port {0}/g' {1}".format(self._port,
                self._conf))
            sudo("sed -i 's/pidfile.*/pidfile \/var\/run\/redis-{0}\.pid/g' {1}".format(
                self._name, self._conf))
            sudo("sed -i 's/dir.*/dir {0}/g' {1}".format(
                self._data_dir.replace('/', '\/'), self._conf))
            sudo("echo \"masterauth {0}\" >> {1}".format(self._password, self._conf))
            sudo("mkdir -p {0}".format(self._data_dir))
            # create supervisor config
            tmpl = """[program:redis-{0}]
command=redis-server {1}
user=root
autostart=true
autorestart=true
redirect_stderr=true
""".format(self._name, self._conf)
            sudo("echo \"{0}\" > {1}".format(tmpl, self._supervisor_conf))
示例#2
0
 def __init__(self, *args, **kwargs):
     super(Redis, self).__init__(*args, **kwargs)
     self._service_name = 'redis'
     self._default_conf = kwargs.get('default_conf', '/etc/redis/redis.conf')
     self._conf = os.path.join(self._conf_dir,
         '{0}.conf'.format(self._service_name))
     self._supervisor_conf = os.path.join(self._supervisor_conf_dir,
         '{0}-{1}.conf'.format(self._name, self._service_name))
     self._data_dir = os.path.join(self._conf_dir, self._service_name)
     self._password = generate_password()
示例#3
0
 def __init__(self, *args, **kwargs):
     super(MySQL, self).__init__(*args, **kwargs)
     self._service_name = "mysql"
     self._default_conf = kwargs.get("default_conf", "/etc/mysql/my.cnf")
     self._default_user = "******"
     self._default_password = kwargs.get("default_password", None)
     self._conf = os.path.join(self._conf_dir, "{0}.cnf".format(self._service_name))
     self._supervisor_conf = os.path.join(
         self._supervisor_conf_dir, "{0}-{1}.conf".format(self._name, self._service_name)
     )
     self._data_dir = os.path.join(self._conf_dir, self._service_name)
     self._mysql_user = "******"
     self._password = generate_password()