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
HasMTLS bool
Debug bool
ShmSize int
SortedHTTPPorts []SortedPortMapping
SortedHTTPSPorts []SortedPortMapping
}
@ -614,6 +615,11 @@ func generateDockerCompose(filePath string, config Config, clientTitle string, c
dockerImage = clientInfo.DockerImage.String
}
shmSize := clientInfo.ShmSize
if shmSize <= 0 {
shmSize = 1
}
data := ComposeData{
ClientTitle: clientTitle,
ContainerNum: containerNum,
@ -624,6 +630,7 @@ func generateDockerCompose(filePath string, config Config, clientTitle string, c
FluentBitEnabled: false,
HasMTLS: hasMTLS,
Debug: clientInfo.Debug,
ShmSize: shmSize,
SortedHTTPPorts: allHTTPPorts,
SortedHTTPSPorts: allHTTPSPorts,
}
@ -640,7 +647,7 @@ func generateDockerCompose(filePath string, config Config, clientTitle string, c
ptaf-{{.ClientTitle}}-agent{{printf "%03d" .ContainerNum}}:
image: '{{.DockerImage}}'
restart: unless-stopped
shm_size: '1gb'
shm_size: '{{.ShmSize}}gb'
container_name: ptaf_{{.ClientTitle}}_{{printf "%03d" .ContainerNum}}
hostname: ptaf_{{.ClientTitle}}_{{printf "%03d" .ContainerNum}}
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) {
query := `
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
WHERE waf_instance = $1
`
@ -125,6 +125,7 @@ func getClientInfoByInstance(db *sql.DB, instance string) ([]ClientInfo, error)
&ci.DockerImage,
&ci.DockerImageDownload,
&ci.Debug,
&ci.ShmSize,
)
if err != nil {
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) {
query := `
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
WHERE client_title = $1
`
@ -224,6 +225,7 @@ func getClientInfoByClientTitle(db *sql.DB, clientTitle string) (*ClientInfo, er
&clientInfo.DockerImage,
&clientInfo.DockerImageDownload,
&clientInfo.Debug,
&clientInfo.ShmSize,
)
if err != nil {
if strings.Contains(err.Error(), "does not exist") {

View file

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