### Python: Setup and Basic Operations with Boto3 SDK Source: https://beget.com/ru/kb/faq/cloud/podklyuchenie-k-obektnomu-hranilishchu-s3-pri-pomoshchi-klientov-aws-cli-s3cmd-cyberduck-sdk This snippet demonstrates the setup process for the boto3 SDK, including creating a project directory, setting up a virtual environment, and installing the library. It then provides examples for uploading objects from a string and a file, listing objects in a bucket, and retrieving an object's content. Proper authorization configuration is required before running the code. ```bash mkdir pyboto3 cd pyboto3 python3 -m venv .venv source .venv/bin/activate python -m pip install boto3 ``` ```python #!/usr/bin/env python #-*- coding: utf-8 -*- import boto3 session = boto3.session.Session() s3 = session.client( service_name='s3', ) bucket_name = 'название_бакета' # Загрузить объекты в бакет ## Из строки s3.put_object(Bucket=bucket_name, Key='object_name', Body='TEST') ## Из файла s3.upload_file('main.py', bucket_name, 'py_script.py') s3.upload_file('main.py', bucket_name, 'script/py_script.py') # Получить список объектов в бакете for key in s3.list_objects(Bucket=bucket_name)['Contents']: print(key['Key']) # Удалить несколько объектов # forDeletion = [{'Key':'object_name'}, {'Key':'script/py_script.py'}] # response = s3.delete_objects(Bucket='bucket-name', Delete={'Objects': forDeletion}) # Получить объект get_object_response = s3.get_object(Bucket=bucket_name,Key='py_script.py') print(get_object_response['Body'].read()) ``` -------------------------------- ### Restart Docker Containers Source: https://beget.com/ru/kb/how-to/vps/vikunja-task-manager After modifying the compose.yml file, restart the Docker containers to apply the changes. This involves stopping the current containers and then starting them again in detached mode. ```bash docker compose down docker compose up -d ``` -------------------------------- ### Открытие файла конфигурации базы данных Source: https://beget.com/ru/kb/how-to/web-apps/ruby Открывает файл `config/database.yml` в текстовом редакторе `nano` для редактирования. Этот файл содержит настройки подключения к базе данных для различных окружений (development, production). ```bash nano config/database.yml ``` -------------------------------- ### Install TorchSR Library Source: https://beget.com/ru/kb/how-to/vps/ustanovka-i-nastrojka-pytorch This command installs the TorchSR library and its necessary dependencies using the pip package manager. Ensure you have pip and Python installed. ```bash pip install torchsr ``` -------------------------------- ### Add Vector Repository and Install (Bash) Source: https://beget.com/ru/kb/how-to/vps/vector-servis-sbora-logov Installs Vector on the aggregator server using the distribution's package manager (apt). It involves downloading a repository setup script, adding the repository, and then installing the 'vector' package. ```bash curl -L -o repo.sh https://setup.vector.dev less repo.sh bash repo.sh rm repo.sh apt install vector ``` -------------------------------- ### Копирование конфигурации базы данных Source: https://beget.com/ru/kb/how-to/web-apps/ruby Создает копию файла `config/database.yml.example` в `config/database.yml`. Это позволяет сохранить исходный пример конфигурации и начать настройку подключения к базе данных для вашего приложения Redmine. ```bash cp config/database.yml.example config/database.yml ``` -------------------------------- ### Install Go Dependencies for PostgreSQL Source: https://beget.com/ru/kb/faq/cloud/oblachnyj-postgresql-podklyuchenie-k-baze-dannyh Installs necessary Go and Git packages and initializes a Go module for a PostgreSQL connection example. This ensures the 'pgx/v4' library is available for use. ```bash sudo apt update && sudo apt install --yes golang git && go mod init example && go get github.com/jackc/pgx/v4 ``` -------------------------------- ### Verify PyTorch Installation with Tensor Operations Source: https://beget.com/ru/kb/how-to/vps/ustanovka-i-nastrojka-pytorch Verifies the PyTorch installation by importing the library, creating a tensor, and performing an addition operation within the Python interpreter. This confirms that PyTorch is functional. ```python import torch a = torch.Tensor([1, 2, 3]) torch.add(a, 2) ``` -------------------------------- ### Make Podlet Executable and Install Source: https://beget.com/ru/kb/how-to/vps/rootless-kontejnery-v-podman-kak-systemd These commands first grant execute permissions to the `podlet` binary using `chmod +x` and then copy it to the `/usr/bin` directory using `sudo cp`, making it available system-wide. ```bash sudo chmod +x podlet && sudo cp podlet /usr/bin/ ``` -------------------------------- ### Enable and Start Vector Aggregator Service (Bash) Source: https://beget.com/ru/kb/how-to/vps/vector-servis-sbora-logov Enables the Vector aggregator service to start on boot and then starts the service immediately. These commands are used to manage the Vector service on the aggregator server. ```bash systemctl enable vector systemctl start vector ``` -------------------------------- ### Переход в каталог сайта Source: https://beget.com/ru/kb/how-to/web-apps/ruby Изменяет текущий рабочий каталог на `betutorial`. Это необходимо для выполнения последующих команд установки и настройки Redmine внутри директории вашего проекта. ```bash cd betutorial ``` -------------------------------- ### Install PyTorch, Torchvision, and Torchaudio for CPU Source: https://beget.com/ru/kb/how-to/vps/ustanovka-i-nastrojka-pytorch Installs the latest versions of PyTorch, torchvision, and torchaudio optimized for CPU execution using pip. This command specifies a specific index URL for CPU-compiled wheels. ```bash pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu ``` -------------------------------- ### Go: Create Project Directory and Initialize Go Module Source: https://beget.com/ru/kb/faq/cloud/podklyuchenie-k-obektnomu-hranilishchu-s3-pri-pomoshchi-klientov-aws-cli-s3cmd-cyberduck-sdk This snippet shows the commands to create a new project directory and initialize a Go module. This is the first step in setting up a Go project for interacting with cloud storage. ```bash mkdir gos3 cd gos3 go mod init example ``` -------------------------------- ### Pull and Start Vector Docker Container (Bash) Source: https://beget.com/ru/kb/how-to/vps/vector-servis-sbora-logov Commands to pull the Vector Docker image and start the Vector agent container in detached mode. These commands are executed after the 'compose.yaml' file is created. ```bash docker compose pull docker compose up -d ``` -------------------------------- ### Пример PHP-скрипта для проверки настройки сайта Source: https://beget.com/ru/kb/how-to/other/multisajtovost-na-dvizhke-bitrix Простой PHP-скрипт, который выводит ID текущего сайта. Помогает проверить, правильно ли Bitrix определяет сайт при обращении к скрипту через браузер. Требует наличия Bitrix. ```php ``` -------------------------------- ### Run Upscaling Script (Bash) Source: https://beget.com/ru/kb/how-to/vps/ustanovka-i-nastrojka-pytorch Executes the Python image upscaling script. It takes the path to the input image as a command-line argument. ```bash python upsample.py assets/beget_logo_normal_3d.jpg ``` -------------------------------- ### Проверка работы скрипта на сайте Source: https://beget.com/ru/kb/how-to/other/multisajtovost-na-dvizhke-bitrix URL для доступа к PHP-скрипту 'test.php', размещенному в корневых папках двух разных сайтов. Используется для проверки корректности настройки сайтов в Bitrix. ```text http://site1.ru/test.php ``` ```text http://site2.ru/test.php ``` -------------------------------- ### Docker Compose Configuration for Vikunja and PostgreSQL Source: https://beget.com/ru/kb/how-to/vps/vikunja-task-manager This YAML file defines the Docker services for Vikunja and its PostgreSQL database. It specifies container images, environment variables (including sensitive ones like passwords and JWT secrets), volume mounts for data persistence, and network dependencies. The database health check ensures Vikunja starts only after the database is ready. ```yaml services: vikunja: image: vikunja/vikunja environment: VIKUNJA_SERVICE_PUBLICURL: "${VIKUNJA_SERVICE_PUBLICURL}" VIKUNJA_DATABASE_HOST: db VIKUNJA_DATABASE_PASSWORD: "${POSTGRES_PASSWORD}" VIKUNJA_DATABASE_TYPE: postgres VIKUNJA_DATABASE_USER: vikunja VIKUNJA_DATABASE_DATABASE: vikunja VIKUNJA_SERVICE_JWTSECRET: "${VIKUNJA_SERVICE_JWTSECRET}" VIKUNJA_SERVICE_ALLOWICONCHANGES: false ports: - 3456:3456 volumes: - ./files:/app/vikunja/files depends_on: db: condition: service_healthy restart: unless-stopped db: image: postgres:17 environment: POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}" POSTGRES_USER: vikunja volumes: - ./db:/var/lib/postgresql/data restart: unless-stopped healthcheck: test: ["CMD-SHELL", "pg_isready -h localhost -U $$POSTGRES_USER"] interval: 2s start_period: 30s ``` -------------------------------- ### Пример абсолютных путей к корневым папкам сайтов Source: https://beget.com/ru/kb/how-to/other/multisajtovost-na-dvizhke-bitrix Примеры абсолютных путей к корневым папкам веб-сервера для двух сайтов. Эти пути используются при настройке сайтов в Bitrix. ```text /home/d/deniatest/site1.ru/public_html ``` ```text /home/d/deniatest/site2.ru/public_html ``` -------------------------------- ### Create Project Directory and Assets Folder Source: https://beget.com/ru/kb/how-to/vps/ustanovka-i-nastrojka-pytorch Creates a project directory and a sub-directory for assets using the mkdir command. This is a prerequisite for setting up the PyTorch environment. ```bash mkdir ~/pytorch_example cd ~/pytorch_example mkdir assets ``` -------------------------------- ### Download Test Image (Bash) Source: https://beget.com/ru/kb/how-to/vps/ustanovka-i-nastrojka-pytorch Downloads a test image (Beget logo) from a given URL and saves it to the 'assets' directory. This command is typically executed in a Unix-like terminal. ```bash wget -P assets https://cp.beget.com/shared/LEX3TOus5TPrFwUm3iIsw_Dm7wg16jU-/beget_logo_normal_3d.jpg ``` -------------------------------- ### API Example Call: Add Virtual Domain Source: https://beget.com/ru/kb/api/obshhij-princzip-raboty-s-api Demonstrates how to add a virtual domain using the Beget.API. This example highlights the use of `input_format=json` and `output_format=json`, with the domain details provided in a URL-encoded JSON string within the `input_data` parameter. ```http https://api.beget.com/api/domain/addVirtual?login=user&passwd=password&input_format=json&output_format=json&input_data=%7B%22hostname%22%3A%22test-domain%22%2C%22zone_id%22%3A1%7D ``` -------------------------------- ### Указание пути к корневой папке сайта в Bitrix Source: https://beget.com/ru/kb/how-to/other/multisajtovost-na-dvizhke-bitrix Настройка пути к корневой папке веб-сервера для нового сайта в административной панели Bitrix. Функция 'Вставить текущий' позволяет автоматически подставить правильный путь. ```text Путь к корневой папке веб-сервера для этого сайта ``` -------------------------------- ### Example log output from hello-world container Source: https://beget.com/ru/kb/how-to/vps/vector-servis-sbora-logov This is an example of the log data captured after running the 'hello-world' container. It includes details such as container creation time, ID, name, image, host, source type, stream, and timestamp. This data is then compressed and stored in object storage. ```json {"container_created_at":"2025-08-20T06:12:37.535496666Z","container_id":"1e41367c029b04d00e5365a628d4b6a0bf20b55f57b0c9a23eff983505ca4fdb","container_name":"inspiring_brahmagupta","host":"e407c846511e","image":"hello-world","message":"","source_type":"docker_logs","stream":"stdout","timestamp":"2025-08-20T06:12:38.954183279Z"} {"container_created_at":"2025-08-20T06:12:37.535496666Z","container_id":"1e41367c029b04d00e5365a628d4b6a0bf20b55f57b0c9a23eff983505ca4fdb","container_name":"inspiring_brahmagupta","host":"e407c846511e","image":"hello-world","message":"Hello from Docker!","source_type":"docker_logs","stream":"stdout","timestamp":"2025-08-20T06:12:38.954307381Z"} {"container_created_at":"2025-08-20T06:12:37.535496666Z","container_id":"1e41367c029b04d00e5365a628d4b6a0bf20b55f57b0c9a23eff983505ca4fdb","container_name":"inspiring_brahmagupta","host":"e407c846511e","image":"hello-world","message":"This message shows that your installation appears to be working correctly.","source_type":"docker_logs","stream":"stdout","timestamp":"2025-08-20T06:12:38.954328888Z"} ... {"container_created_at":"2025-08-20T06:12:38.558644762Z","container_id":"fb50713b279b94d06e86079f2e7db0f91fd42773ff9e9da7f5f32b8d30aec632","container_name":"zen_dijkstra","host":"81fcb2d44535","image":"hello-world","message":" https://docs.docker.com/get-started/","source_type":"docker_logs","stream":"stdout","timestamp":"2025-08-20T06:12:40.113742206Z"} {"container_created_at":"2025-08-20T06:12:38.558644762Z","container_id":"fb50713b279b94d06e86079f2e7db0f91fd42773ff9e9da7f5f32b8d30aec632","container_name":"zen_dijkstra","host":"81fcb2d44535","image":"hello-world","message":"","source_type":"docker_logs","stream":"stdout","timestamp":"2025-08-20T06:12:40.113769278Z"} ``` -------------------------------- ### Настройка подключения к базе данных для Production Source: https://beget.com/ru/kb/how-to/web-apps/ruby Конфигурирует параметры подключения к базе данных MySQL для производственного окружения (production) в файле `config/database.yml`. Включает имя базы данных, пользователя, пароль и хост. ```yaml production: adapter: mysql2 database: betutorial_redmine host: localhost username: betutorial_redmine password: "AX@8lBCo79zz" encoding: utf8mb4 ```