Файловый менеджер - Редактировать - /opt/cpmigrate/environments/redis.py
Ðазад
"""Redis Environment Module""" from environments.base import Environment class Redis(Environment): """ Checks if Redis is installed on the origin and configures it on the new server. """ def __init__(self): Environment.__init__(self) self.redis_installed = False def check(self, _): self.check_origin_redis() def check_origin_redis(self): """Checks if Redis is installed on the origin server.""" self.redis_installed = self.xfer.check_origin_package('redis') if self.redis_installed: self.info("Detected Redis installation on origin server.") self.actions.append("+ Install epel-release.") self.actions.append("+ Install Redis.") else: self.info("No Redis detected.") def run(self, _): if self.install_epel(): if self.install_redis(): self.enable_redis() self.start_redis() def install_epel(self): """Installs epel-release which is required for installing Redis. Returns: bool: whether or not the install was successful """ self.info("Installing epel-release.") ret_code, _ = self.xfer.local_command( ['/usr/bin/yum', 'install', '-y', "epel-release"], sleep=2 ) if ret_code == 0: self.info("Installed epel-release successfully.") return True self.error( "Failed to install epel-release, cannot continue installing " "redis. Please install manually." ) return False def install_redis(self): """Installs the redis package on the target server. Returns: bool: whether or not the install was successful """ self.info("Installing redis.") ret_code, _ = self.xfer.local_command( ['/usr/bin/yum', 'install', '-y', "redis"], sleep=2 ) if ret_code == 0: self.info("Installed redis successfully.") return True self.error("Failed to install redis, please install manually.") return False def enable_redis(self): """ Enables redis in systemd on the target server. """ ret_code, _ = self.xfer.local_command( ['/usr/bin/systemctl', 'enable', 'redis'], quiet=True, sleep=1 ) if ret_code == 0: self.info("Enabled redis successfully.") else: self.warning("Failed to enable redis with systemd.", note=True) def start_redis(self): """ Starts redis in systemd on the target server. """ ret_code, _ = self.xfer.local_command( ['/usr/bin/systemctl', 'start', 'redis'], quiet=True, sleep=1 ) if ret_code == 0: self.info("Started redis successfully.") else: self.warning("Failed to start redis with systemd.", note=True)
| ver. 1.1 | |
.
| PHP 8.3.30 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка