mirror of
https://github.com/askh/pypimirror.git
synced 2026-02-10 07:39:55 +00:00
Add the read timeout option.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
SERVER_IP=0.0.0.0
|
||||
SERVER_PORT=3141
|
||||
ROOT_PASSWORD=root
|
||||
REQUEST_TIMEOUT_SEC=10
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Конфигурационные файлы для запуска частичного зеркала PyPi используя docker-compose
|
||||
# Конфигурационные файлы для запуска частичного зеркала PyPI используя docker-compose
|
||||
|
||||
Конфигурационные файлы предназначены для развёртывания зеркала PyPi для
|
||||
локального применения, например, на случай, если доступ к серверам PyPi окажется
|
||||
Конфигурационные файлы предназначены для развёртывания зеркала PyPI для
|
||||
локального применения, например, на случай, если доступ к серверам PyPI окажется
|
||||
заблокирован. Используется [devpi](https://devpi.net/), который запускается
|
||||
используя docker-compose.
|
||||
|
||||
|
||||
@@ -2,3 +2,6 @@
|
||||
index-url=http://mirror.example.com:3141/root/pypi/+simple/
|
||||
trusted-host=mirror.example.com
|
||||
timeout=120
|
||||
|
||||
[search]
|
||||
index=http://mirror.example.com:3141/root/pypi/
|
||||
|
||||
@@ -6,6 +6,8 @@ import subprocess
|
||||
from dotenv import dotenv_values
|
||||
import yaml
|
||||
|
||||
DEFAULT_REQUEST_TIMEOUT_SEC = 10
|
||||
|
||||
arg_parser = argparse.ArgumentParser(description="The script for start devpi-server")
|
||||
arg_parser.add_argument(
|
||||
'-d',
|
||||
@@ -21,19 +23,29 @@ config_dir = os.path.join(args.data_dir, "config")
|
||||
env_file = os.path.join(config_dir, ".env")
|
||||
config_file = os.path.join(config_dir, "devpi.conf")
|
||||
|
||||
if not(os.path.exists(args.data_dir) and os.path.isdir(args.data_dir)):
|
||||
sys.exit(f"The data directory {args.data_dir} not available.")
|
||||
for subdir_path in [server_dir, config_dir]:
|
||||
if not os.path.exists(subdir_path):
|
||||
os.mkdir(subdir_path, mode=0o770)
|
||||
|
||||
if not os.path.exists(config_file):
|
||||
env_config_values = dotenv_values(env_file) if os.path.isfile(env_file) else { }
|
||||
|
||||
config_data = {
|
||||
'devpi-server': {
|
||||
'serverdir': os.path.abspath(server_dir),
|
||||
'host': '0.0.0.0',
|
||||
'restrict-modify': 'root'
|
||||
'restrict-modify': 'root',
|
||||
'request-timeout': int(env_config_values.get('REQUEST_TIMEOUT_SEC') or \
|
||||
DEFAULT_REQUEST_TIMEOUT_SEC)
|
||||
}
|
||||
}
|
||||
if os.path.isfile(env_file):
|
||||
env_config_values = dotenv_values(env_file)
|
||||
if 'ROOT_PASSWORD' in env_config_values.keys():
|
||||
config_data['devpi-server']['root-passwd'] = \
|
||||
env_config_values['ROOT_PASSWORD']
|
||||
}
|
||||
|
||||
if 'ROOT_PASSWORD' in env_config_values.keys():
|
||||
config_data['devpi-server']['root-passwd'] = \
|
||||
env_config_values['ROOT_PASSWORD']
|
||||
|
||||
with open(config_file, 'w') as file:
|
||||
yaml.dump(config_data, file)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user