shm_memmory change

This commit is contained in:
Magnus Root 2026-03-25 16:47:57 +03:00
parent 55b7be8e65
commit d609591010
3 changed files with 13 additions and 3 deletions

View file

@ -567,6 +567,7 @@ func generateDockerCompose(filePath string, config Config, clientTitle string, c
FluentBitPort int FluentBitPort int
HasMTLS bool HasMTLS bool
Debug bool Debug bool
ShmSize int
SortedHTTPPorts []SortedPortMapping SortedHTTPPorts []SortedPortMapping
SortedHTTPSPorts []SortedPortMapping SortedHTTPSPorts []SortedPortMapping
} }
@ -614,6 +615,11 @@ func generateDockerCompose(filePath string, config Config, clientTitle string, c
dockerImage = clientInfo.DockerImage.String dockerImage = clientInfo.DockerImage.String
} }
shmSize := clientInfo.ShmSize
if shmSize <= 0 {
shmSize = 1
}
data := ComposeData{ data := ComposeData{
ClientTitle: clientTitle, ClientTitle: clientTitle,
ContainerNum: containerNum, ContainerNum: containerNum,
@ -624,6 +630,7 @@ func generateDockerCompose(filePath string, config Config, clientTitle string, c
FluentBitEnabled: false, FluentBitEnabled: false,
HasMTLS: hasMTLS, HasMTLS: hasMTLS,
Debug: clientInfo.Debug, Debug: clientInfo.Debug,
ShmSize: shmSize,
SortedHTTPPorts: allHTTPPorts, SortedHTTPPorts: allHTTPPorts,
SortedHTTPSPorts: allHTTPSPorts, SortedHTTPSPorts: allHTTPSPorts,
} }
@ -640,7 +647,7 @@ func generateDockerCompose(filePath string, config Config, clientTitle string, c
ptaf-{{.ClientTitle}}-agent{{printf "%03d" .ContainerNum}}: ptaf-{{.ClientTitle}}-agent{{printf "%03d" .ContainerNum}}:
image: '{{.DockerImage}}' image: '{{.DockerImage}}'
restart: unless-stopped restart: unless-stopped
shm_size: '1gb' shm_size: '{{.ShmSize}}gb'
container_name: ptaf_{{.ClientTitle}}_{{printf "%03d" .ContainerNum}} container_name: ptaf_{{.ClientTitle}}_{{printf "%03d" .ContainerNum}}
hostname: ptaf_{{.ClientTitle}}_{{printf "%03d" .ContainerNum}} hostname: ptaf_{{.ClientTitle}}_{{printf "%03d" .ContainerNum}}
environment: environment:

6
db.go
View file

@ -98,7 +98,7 @@ func checkHostBelongsToInstance(db *sql.DB, hostname, instance string) (bool, er
func getClientInfoByInstance(db *sql.DB, instance string) ([]ClientInfo, error) { func getClientInfoByInstance(db *sql.DB, instance string) ([]ClientInfo, error) {
query := ` query := `
SELECT containers_count, ptaf_config, client_title, fluent_bit_port, waf_instance, SELECT containers_count, ptaf_config, client_title, fluent_bit_port, waf_instance,
docker_image, docker_image_download, debug docker_image, docker_image_download, debug, shm_size
FROM client_info FROM client_info
WHERE waf_instance = $1 WHERE waf_instance = $1
` `
@ -125,6 +125,7 @@ func getClientInfoByInstance(db *sql.DB, instance string) ([]ClientInfo, error)
&ci.DockerImage, &ci.DockerImage,
&ci.DockerImageDownload, &ci.DockerImageDownload,
&ci.Debug, &ci.Debug,
&ci.ShmSize,
) )
if err != nil { if err != nil {
return nil, fmt.Errorf("ошибка сканирования строки: %w", err) return nil, fmt.Errorf("ошибка сканирования строки: %w", err)
@ -208,7 +209,7 @@ func getAppsSettingsByClientTitle(db *sql.DB, clientTitle string) ([]AppsSetting
func getClientInfoByClientTitle(db *sql.DB, clientTitle string) (*ClientInfo, error) { func getClientInfoByClientTitle(db *sql.DB, clientTitle string) (*ClientInfo, error) {
query := ` query := `
SELECT containers_count, ptaf_config, client_title, fluent_bit_port, waf_instance, SELECT containers_count, ptaf_config, client_title, fluent_bit_port, waf_instance,
docker_image, docker_image_download, debug docker_image, docker_image_download, debug, shm_size
FROM client_info FROM client_info
WHERE client_title = $1 WHERE client_title = $1
` `
@ -224,6 +225,7 @@ func getClientInfoByClientTitle(db *sql.DB, clientTitle string) (*ClientInfo, er
&clientInfo.DockerImage, &clientInfo.DockerImage,
&clientInfo.DockerImageDownload, &clientInfo.DockerImageDownload,
&clientInfo.Debug, &clientInfo.Debug,
&clientInfo.ShmSize,
) )
if err != nil { if err != nil {
if strings.Contains(err.Error(), "does not exist") { if strings.Contains(err.Error(), "does not exist") {

View file

@ -50,6 +50,7 @@ type ClientInfo struct {
DockerImage sql.NullString // Образ Docker для контейнеров клиента DockerImage sql.NullString // Образ Docker для контейнеров клиента
DockerImageDownload sql.NullString // URL для скачивания образа DockerImageDownload sql.NullString // URL для скачивания образа
Debug bool // Режим отладки (влияет на лог-уровень и переменные окружения) Debug bool // Режим отладки (влияет на лог-уровень и переменные окружения)
ShmSize int // Размер /dev/shm в GB (дефолт 1)
} }
// Структуры для API ответов // Структуры для API ответов