PATH:
opt
/
cloudlinux
/
venv
/
lib
/
python3.11
/
site-packages
/
clwpos
/
object_cache
/
__pycache__
� �O�:��Ov� �$ � d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZm Z d dl mZ d dlm Z d dlmZ d dlmZ d dlmZ d d lmZ d d lmZ d dlmZ d dlmZmZ d d lmZmZ d dl m!Z!m"Z" d dl#m$Z$ d dl%m&Z& d dl'm(Z( d dl)m*Z* d dl+m,Z, dZ- e*� � Z.de/de/fd�Z0de/de/de/de/de/de/de/fd�Z1dede/de/d ee/ dee/ f d!�Z2dede/d"e3de/d#e4de5fd$�Z6d%e5de/ddfd&�Z7d'ede/de/de4fd(�Z8d)e3de5fd*�Z9 d0de/d)e3d'e e d-e5d.e/de4fd/�Z:dS )1� N)�Logger)�List�Optional)�write_file_via_tempfile)�drop_user_privileges)�userdomains)�Feature)�is_panel_feature_supported)�demote)�gettext)� WposError)�&_get_redis_pid_from_pid_file_with_wait�kill_process_by_pid)� USER_WPOS_DIR�is_run_under_user)� UserConfig�ConfigError)�OBJECT_CACHE_FEATURE)�get_allowed_modules)�REDIS_SERVER_BIN_FILE)� NullLogger)� NoPackageaS # !!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT maxclients {maxclients} databases 16 maxmemory-policy allkeys-lru appendonly no appendfsync always loglevel warning logfile {logfile} # Disable TCP ports using port 0 unixsocket {socket_path} unixsocketperm 600 dir {clwpos_dir} maxmemory {maxmemory} save "" pidfile {pidfile} �redis_config_path�returnc �D � t j � | � � r�t | � � 5 }|� � � }t j d|t j �� � }|�!|� d� � cddd� � S ddd� � n# 1 swxY w Y dS )a Read and return maxclients value from the Redis config file if config file exists maxclients is integer value. Return default value otherwise. :param redis_config_path: path to Redis configuration file :return: maxclients value from config or default zmaxclients (\d+)$)�flagsN� �16) �os�path�exists�open�read�re�search� MULTILINE�group)r �redis_config�config�values �,py/clwpos/object_cache/reloader_redis_lib.py�_read_maxclients_from_configr, = s� � � �w�~�~�'�(�(� &� �#� $� $� &��!�&�&�(�(�F��I�2�F�"�,�O�O�O�E�� ��{�{�1�~�~� &� &� &� &� &� &� &� &� !� &� &� &� &� &� &� &� &� &� &� &���� &� &� &� &� �4s �AB�B�B�username�user_homedir� clwpos_dir�redis_socket_path� maxmemory�pidfile_pathc � � t |� � }t � |t j � t j � |� � d� � ||||�� � } t j � |t � � } t j |d�� � nH# t t f$ r4} t t d� � t d� � || d��� � �d } ~ ww xY wt ||d � � d S # t t f$ r4} t t d� � t d� � | | d��� � �d } ~ ww xY w) a� Writes redis config for user (call under drop_privileges) :param username: User name for write config :param user_homedir: User's homedir :param redis_socket_path: Full path to user's redis socket :param redis_config_path: Full path to user's redis config file :param maxmemory: maxmemory value to write to redis config :param pidfile_path: Redis pid file path :return: None z redis.log)� maxclients�logfile�socket_pathr/ r1 �pidfileT)�exist_okz&Can't create directory %(directory)s. z5The operating system reported error: %(system_error)s)� directory�system_error)�message�details�contextNi� z>Error happened while writing redis config for user '%(user)s' )�userr: )r, �_USER_REDIS_CONF_PATTERN�formatr r �join�dirnamer �makedirs�OSError�IOErrorr �_r ) r- r. r/ r0 r r1 r2 r4 �redis_config_contentr: s r+ �_write_redis_config_for_userrH O s| � � .�.?�@�@�J�3�:�:������R�W�_�_�->�?�?��M�M�%���� ;� � �� R��W�\�\�,� �>�>� � ]��K� �T�2�2�2�2�2����"� ]� ]� ]��A�&N�$O�$O�$%�&]�$^�$^�2<�l�$[�$[�]� ]� ]� ]����� ]���� � 4�6G��O�O�O�O�O���W�� R� R� R���"b� c� c� !�"Y� Z� Z�)1�<� P� P�R� R� R� R�����R���s<