wexample-wex-addon-services-db 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wexample_wex_addon_services_db/__init__.py +7 -0
- wexample_wex_addon_services_db/py.typed +0 -0
- wexample_wex_addon_services_db/services/__init__.py +0 -0
- wexample_wex_addon_services_db/services/elasticsearch/__init__.py +0 -0
- wexample_wex_addon_services_db/services/elasticsearch/app_service.py +29 -0
- wexample_wex_addon_services_db/services/elasticsearch/commands/__init__.py +0 -0
- wexample_wex_addon_services_db/services/elasticsearch/commands/service/__init__.py +0 -0
- wexample_wex_addon_services_db/services/elasticsearch/commands/service/install.py +31 -0
- wexample_wex_addon_services_db/services/elasticsearch/commands/service/ready.py +41 -0
- wexample_wex_addon_services_db/services/elasticsearch/docker/__init__.py +0 -0
- wexample_wex_addon_services_db/services/elasticsearch/docker/docker-compose.yml +27 -0
- wexample_wex_addon_services_db/services/elasticsearch/service.yml +6 -0
- wexample_wex_addon_services_db/services/maria/__init__.py +0 -0
- wexample_wex_addon_services_db/services/maria/commands/__init__.py +1 -0
- wexample_wex_addon_services_db/services/maria/commands/config/__init__.py +1 -0
- wexample_wex_addon_services_db/services/maria/commands/config/runtime.py +22 -0
- wexample_wex_addon_services_db/services/maria/commands/db/__init__.py +1 -0
- wexample_wex_addon_services_db/services/maria/commands/db/connect.py +24 -0
- wexample_wex_addon_services_db/services/maria/commands/db/destroy.py +30 -0
- wexample_wex_addon_services_db/services/maria/commands/db/dump.py +32 -0
- wexample_wex_addon_services_db/services/maria/commands/db/dumps_list.py +31 -0
- wexample_wex_addon_services_db/services/maria/commands/db/exec.py +31 -0
- wexample_wex_addon_services_db/services/maria/commands/db/go.py +24 -0
- wexample_wex_addon_services_db/services/maria/commands/db/restore.py +44 -0
- wexample_wex_addon_services_db/services/maria/commands/service/__init__.py +1 -0
- wexample_wex_addon_services_db/services/maria/commands/service/install.py +25 -0
- wexample_wex_addon_services_db/services/maria/commands/service/ready.py +23 -0
- wexample_wex_addon_services_db/services/maria/docker/__init__.py +0 -0
- wexample_wex_addon_services_db/services/maria/docker/docker-compose.yml +18 -0
- wexample_wex_addon_services_db/services/maria/samples/__init__.py +0 -0
- wexample_wex_addon_services_db/services/maria/samples/docker/__init__.py +0 -0
- wexample_wex_addon_services_db/services/maria/samples/docker/docker-compose.yml +5 -0
- wexample_wex_addon_services_db/services/maria/samples/maria/__init__.py +0 -0
- wexample_wex_addon_services_db/services/maria/samples/maria/data/.gitkeep +1 -0
- wexample_wex_addon_services_db/services/maria/samples/maria/data/__init__.py +0 -0
- wexample_wex_addon_services_db/services/maria/samples/maria/dumps/.gitkeep +1 -0
- wexample_wex_addon_services_db/services/maria/samples/maria/dumps/__init__.py +0 -0
- wexample_wex_addon_services_db/services/maria/samples/maria/my.cnf +1 -0
- wexample_wex_addon_services_db/services/maria/service.yml +4 -0
- wexample_wex_addon_services_db/services/mongo/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mongo/app_service.py +32 -0
- wexample_wex_addon_services_db/services/mongo/commands/__init__.py +1 -0
- wexample_wex_addon_services_db/services/mongo/commands/config/__init__.py +1 -0
- wexample_wex_addon_services_db/services/mongo/commands/config/runtime.py +32 -0
- wexample_wex_addon_services_db/services/mongo/commands/db/__init__.py +1 -0
- wexample_wex_addon_services_db/services/mongo/commands/db/destroy.py +83 -0
- wexample_wex_addon_services_db/services/mongo/commands/db/dump.py +58 -0
- wexample_wex_addon_services_db/services/mongo/commands/db/dumps_list.py +43 -0
- wexample_wex_addon_services_db/services/mongo/commands/db/exec.py +45 -0
- wexample_wex_addon_services_db/services/mongo/commands/db/go.py +33 -0
- wexample_wex_addon_services_db/services/mongo/commands/db/restore.py +65 -0
- wexample_wex_addon_services_db/services/mongo/commands/service/__init__.py +1 -0
- wexample_wex_addon_services_db/services/mongo/commands/service/install.py +32 -0
- wexample_wex_addon_services_db/services/mongo/commands/service/ready.py +44 -0
- wexample_wex_addon_services_db/services/mongo/commands/service/setup.py +27 -0
- wexample_wex_addon_services_db/services/mongo/docker/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mongo/docker/docker-compose.yml +10 -0
- wexample_wex_addon_services_db/services/mongo/samples/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mongo/samples/mongo/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mongo/samples/mongo/data/.gitkeep +1 -0
- wexample_wex_addon_services_db/services/mongo/samples/mongo/data/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mongo/samples/mongo/dumps/.gitkeep +1 -0
- wexample_wex_addon_services_db/services/mongo/samples/mongo/dumps/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mongo/service.yml +7 -0
- wexample_wex_addon_services_db/services/mysql/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mysql/commands/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mysql/commands/config/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mysql/commands/config/runtime.py +54 -0
- wexample_wex_addon_services_db/services/mysql/commands/db/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mysql/commands/db/connect.py +20 -0
- wexample_wex_addon_services_db/services/mysql/commands/db/destroy.py +54 -0
- wexample_wex_addon_services_db/services/mysql/commands/db/dump.py +63 -0
- wexample_wex_addon_services_db/services/mysql/commands/db/dumps_list.py +39 -0
- wexample_wex_addon_services_db/services/mysql/commands/db/exec.py +46 -0
- wexample_wex_addon_services_db/services/mysql/commands/db/go.py +40 -0
- wexample_wex_addon_services_db/services/mysql/commands/db/restore.py +60 -0
- wexample_wex_addon_services_db/services/mysql/commands/service/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mysql/commands/service/install.py +36 -0
- wexample_wex_addon_services_db/services/mysql/commands/service/ready.py +46 -0
- wexample_wex_addon_services_db/services/mysql/docker/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mysql/docker/docker-compose.yml +15 -0
- wexample_wex_addon_services_db/services/mysql/samples/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mysql/samples/mysql/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mysql/samples/mysql/data/.gitkeep +0 -0
- wexample_wex_addon_services_db/services/mysql/samples/mysql/data/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mysql/samples/mysql/dumps/.gitkeep +0 -0
- wexample_wex_addon_services_db/services/mysql/samples/mysql/dumps/__init__.py +0 -0
- wexample_wex_addon_services_db/services/mysql/samples/mysql/my.cnf +5 -0
- wexample_wex_addon_services_db/services/mysql/service.yml +9 -0
- wexample_wex_addon_services_db/services/neo4j/__init__.py +0 -0
- wexample_wex_addon_services_db/services/neo4j/app_service.py +34 -0
- wexample_wex_addon_services_db/services/neo4j/commands/__init__.py +0 -0
- wexample_wex_addon_services_db/services/neo4j/commands/service/__init__.py +0 -0
- wexample_wex_addon_services_db/services/neo4j/commands/service/install.py +29 -0
- wexample_wex_addon_services_db/services/neo4j/commands/service/ready.py +32 -0
- wexample_wex_addon_services_db/services/neo4j/docker/__init__.py +0 -0
- wexample_wex_addon_services_db/services/neo4j/docker/docker-compose.yml +6 -0
- wexample_wex_addon_services_db/services/neo4j/service.yml +5 -0
- wexample_wex_addon_services_db/services/postgres/__init__.py +0 -0
- wexample_wex_addon_services_db/services/postgres/app_service.py +36 -0
- wexample_wex_addon_services_db/services/postgres/commands/__init__.py +1 -0
- wexample_wex_addon_services_db/services/postgres/commands/config/__init__.py +1 -0
- wexample_wex_addon_services_db/services/postgres/commands/config/runtime.py +32 -0
- wexample_wex_addon_services_db/services/postgres/commands/db/__init__.py +1 -0
- wexample_wex_addon_services_db/services/postgres/commands/db/connect.py +47 -0
- wexample_wex_addon_services_db/services/postgres/commands/db/destroy.py +93 -0
- wexample_wex_addon_services_db/services/postgres/commands/db/dump.py +67 -0
- wexample_wex_addon_services_db/services/postgres/commands/db/dumps_list.py +39 -0
- wexample_wex_addon_services_db/services/postgres/commands/db/exec.py +70 -0
- wexample_wex_addon_services_db/services/postgres/commands/db/go.py +63 -0
- wexample_wex_addon_services_db/services/postgres/commands/db/restore.py +67 -0
- wexample_wex_addon_services_db/services/postgres/commands/service/__init__.py +1 -0
- wexample_wex_addon_services_db/services/postgres/commands/service/install.py +36 -0
- wexample_wex_addon_services_db/services/postgres/commands/service/ready.py +60 -0
- wexample_wex_addon_services_db/services/postgres/docker/__init__.py +0 -0
- wexample_wex_addon_services_db/services/postgres/docker/docker-compose.yml +14 -0
- wexample_wex_addon_services_db/services/postgres/samples/__init__.py +0 -0
- wexample_wex_addon_services_db/services/postgres/samples/postgres/__init__.py +0 -0
- wexample_wex_addon_services_db/services/postgres/samples/postgres/data/.gitkeep +1 -0
- wexample_wex_addon_services_db/services/postgres/samples/postgres/data/__init__.py +0 -0
- wexample_wex_addon_services_db/services/postgres/samples/postgres/dumps/.gitkeep +1 -0
- wexample_wex_addon_services_db/services/postgres/samples/postgres/dumps/__init__.py +0 -0
- wexample_wex_addon_services_db/services/postgres/service.yml +7 -0
- wexample_wex_addon_services_db/services/redis/__init__.py +1 -0
- wexample_wex_addon_services_db/services/redis/commands/__init__.py +1 -0
- wexample_wex_addon_services_db/services/redis/commands/service/__init__.py +1 -0
- wexample_wex_addon_services_db/services/redis/commands/service/install.py +34 -0
- wexample_wex_addon_services_db/services/redis/commands/service/ready.py +46 -0
- wexample_wex_addon_services_db/services/redis/docker/__init__.py +0 -0
- wexample_wex_addon_services_db/services/redis/docker/docker-compose.yml +15 -0
- wexample_wex_addon_services_db/services/redis/samples/__init__.py +0 -0
- wexample_wex_addon_services_db/services/redis/samples/docker/__init__.py +0 -0
- wexample_wex_addon_services_db/services/redis/samples/docker/docker-compose.yml +5 -0
- wexample_wex_addon_services_db/services/redis/samples/redis/__init__.py +0 -0
- wexample_wex_addon_services_db/services/redis/samples/redis/data/.gitkeep +1 -0
- wexample_wex_addon_services_db/services/redis/samples/redis/data/__init__.py +0 -0
- wexample_wex_addon_services_db/services/redis/samples/redis/dumps/.gitkeep +1 -0
- wexample_wex_addon_services_db/services/redis/samples/redis/dumps/__init__.py +0 -0
- wexample_wex_addon_services_db/services/redis/service.yml +5 -0
- wexample_wex_addon_services_db/services/sqlserver/__init__.py +1 -0
- wexample_wex_addon_services_db/services/sqlserver/commands/__init__.py +1 -0
- wexample_wex_addon_services_db/services/sqlserver/commands/config/__init__.py +1 -0
- wexample_wex_addon_services_db/services/sqlserver/commands/config/runtime.py +32 -0
- wexample_wex_addon_services_db/services/sqlserver/commands/db/__init__.py +1 -0
- wexample_wex_addon_services_db/services/sqlserver/commands/db/destroy.py +90 -0
- wexample_wex_addon_services_db/services/sqlserver/commands/db/dump.py +86 -0
- wexample_wex_addon_services_db/services/sqlserver/commands/db/dumps_list.py +39 -0
- wexample_wex_addon_services_db/services/sqlserver/commands/db/exec.py +62 -0
- wexample_wex_addon_services_db/services/sqlserver/commands/db/go.py +59 -0
- wexample_wex_addon_services_db/services/sqlserver/commands/db/restore.py +72 -0
- wexample_wex_addon_services_db/services/sqlserver/commands/service/__init__.py +1 -0
- wexample_wex_addon_services_db/services/sqlserver/commands/service/install.py +36 -0
- wexample_wex_addon_services_db/services/sqlserver/commands/service/ready.py +48 -0
- wexample_wex_addon_services_db/services/sqlserver/docker/__init__.py +0 -0
- wexample_wex_addon_services_db/services/sqlserver/docker/docker-compose.yml +14 -0
- wexample_wex_addon_services_db/services/sqlserver/helpers/__init__.py +1 -0
- wexample_wex_addon_services_db/services/sqlserver/helpers/sqlcmd.py +44 -0
- wexample_wex_addon_services_db/services/sqlserver/samples/__init__.py +0 -0
- wexample_wex_addon_services_db/services/sqlserver/samples/docker/__init__.py +0 -0
- wexample_wex_addon_services_db/services/sqlserver/samples/docker/docker-compose.yml +5 -0
- wexample_wex_addon_services_db/services/sqlserver/samples/sqlserver/__init__.py +0 -0
- wexample_wex_addon_services_db/services/sqlserver/samples/sqlserver/data/.gitkeep +1 -0
- wexample_wex_addon_services_db/services/sqlserver/samples/sqlserver/data/__init__.py +0 -0
- wexample_wex_addon_services_db/services/sqlserver/samples/sqlserver/dumps/.gitkeep +1 -0
- wexample_wex_addon_services_db/services/sqlserver/samples/sqlserver/dumps/__init__.py +0 -0
- wexample_wex_addon_services_db/services/sqlserver/samples/sqlserver/log/.gitkeep +1 -0
- wexample_wex_addon_services_db/services/sqlserver/samples/sqlserver/log/__init__.py +0 -0
- wexample_wex_addon_services_db/services/sqlserver/samples/sqlserver/mssql/.gitkeep +1 -0
- wexample_wex_addon_services_db/services/sqlserver/samples/sqlserver/mssql/__init__.py +0 -0
- wexample_wex_addon_services_db/services/sqlserver/service.yml +7 -0
- wexample_wex_addon_services_db/services_db_addon_manager.py +15 -0
- wexample_wex_addon_services_db-0.0.3.dist-info/METADATA +164 -0
- wexample_wex_addon_services_db-0.0.3.dist-info/RECORD +175 -0
- wexample_wex_addon_services_db-0.0.3.dist-info/WHEEL +4 -0
- wexample_wex_addon_services_db-0.0.3.dist-info/entry_points.txt +4 -0
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from wexample_wex_addon_app.service.app_service import AppService as BaseAppService
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AppService(BaseAppService):
|
|
7
|
+
def get_workdir_contribution(self) -> dict:
|
|
8
|
+
from wexample_filestate.const.disk import DiskItemType
|
|
9
|
+
|
|
10
|
+
# Elasticsearch container runs as uid 1000 (elasticsearch user)
|
|
11
|
+
es_mode = {"owner": "1000:1000", "permissions": "750", "recursive": True}
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
"children": [
|
|
15
|
+
{
|
|
16
|
+
"name": "elasticsearch",
|
|
17
|
+
"type": DiskItemType.DIRECTORY,
|
|
18
|
+
"should_exist": True,
|
|
19
|
+
"children": [
|
|
20
|
+
{
|
|
21
|
+
"name": "data",
|
|
22
|
+
"type": DiskItemType.DIRECTORY,
|
|
23
|
+
"should_exist": True,
|
|
24
|
+
"mode": es_mode,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
]
|
|
29
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from wexample_wex_core.const.globals import COMMAND_TYPE_SERVICE
|
|
6
|
+
from wexample_wex_core.decorator.command import command
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from wexample_wex_addon_app.service.app_service import AppService
|
|
10
|
+
from wexample_wex_core.context.execution_context import ExecutionContext
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@command(
|
|
14
|
+
type=COMMAND_TYPE_SERVICE,
|
|
15
|
+
description="Configure elasticsearch service in app config",
|
|
16
|
+
)
|
|
17
|
+
def elasticsearch__service__install(
|
|
18
|
+
context: ExecutionContext,
|
|
19
|
+
service: AppService,
|
|
20
|
+
) -> None:
|
|
21
|
+
app_name = service.app_workdir.get_config().search("global.name").get_str()
|
|
22
|
+
config_file = service.app_workdir.get_config_file()
|
|
23
|
+
config = config_file.read_config()
|
|
24
|
+
|
|
25
|
+
config.set_by_path(f"service.{service.name}.host", f"{app_name}_{service.name}")
|
|
26
|
+
config.set_by_path(f"service.{service.name}.port", 9200)
|
|
27
|
+
|
|
28
|
+
config_file.write_config(config)
|
|
29
|
+
service.app_workdir.get_runtime_config(rebuild=True)
|
|
30
|
+
|
|
31
|
+
context.io.log(f"Configured elasticsearch service for app '{app_name}'")
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from wexample_wex_core.const.globals import COMMAND_TYPE_SERVICE
|
|
6
|
+
from wexample_wex_core.decorator.command import command
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from wexample_app.response.boolean_response import BooleanResponse
|
|
10
|
+
from wexample_wex_addon_app.service.app_service import AppService
|
|
11
|
+
from wexample_wex_core.context.execution_context import ExecutionContext
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@command(
|
|
15
|
+
type=COMMAND_TYPE_SERVICE, description="Check if elasticsearch service is ready"
|
|
16
|
+
)
|
|
17
|
+
def elasticsearch__service__ready(
|
|
18
|
+
context: ExecutionContext,
|
|
19
|
+
service: AppService,
|
|
20
|
+
) -> BooleanResponse:
|
|
21
|
+
import subprocess
|
|
22
|
+
|
|
23
|
+
from wexample_app.response.boolean_response import BooleanResponse
|
|
24
|
+
|
|
25
|
+
runtime = service.app_workdir.get_runtime_config()
|
|
26
|
+
app_project_name = runtime.search("app.project_name").get_str()
|
|
27
|
+
container_name = f"{app_project_name}_{service.name}"
|
|
28
|
+
|
|
29
|
+
result = subprocess.run(
|
|
30
|
+
[
|
|
31
|
+
"docker",
|
|
32
|
+
"exec",
|
|
33
|
+
container_name,
|
|
34
|
+
"curl",
|
|
35
|
+
"-sf",
|
|
36
|
+
"http://localhost:9200/_cluster/health",
|
|
37
|
+
],
|
|
38
|
+
capture_output=True,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return BooleanResponse(kernel=context.kernel, content=result.returncode == 0)
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
services:
|
|
2
|
+
elasticsearch:
|
|
3
|
+
container_name: ${APP_PROJECT_NAME}_elasticsearch
|
|
4
|
+
image: elasticsearch:9.1.4
|
|
5
|
+
environment:
|
|
6
|
+
- node.name=elasticsearch
|
|
7
|
+
- cluster.name=${APP_PROJECT_NAME}-logging
|
|
8
|
+
- discovery.type=single-node
|
|
9
|
+
- bootstrap.memory_lock=true
|
|
10
|
+
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
|
|
11
|
+
ulimits:
|
|
12
|
+
memlock:
|
|
13
|
+
soft: -1
|
|
14
|
+
hard: -1
|
|
15
|
+
volumes:
|
|
16
|
+
- ${APP_PATH}elasticsearch/data:/usr/share/elasticsearch/data
|
|
17
|
+
ports:
|
|
18
|
+
- "9200:9200"
|
|
19
|
+
- "9300:9300"
|
|
20
|
+
networks:
|
|
21
|
+
- wex_net
|
|
22
|
+
deploy:
|
|
23
|
+
resources:
|
|
24
|
+
limits:
|
|
25
|
+
memory: 6g
|
|
26
|
+
reservations:
|
|
27
|
+
memory: 3g
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from wexample_wex_core.const.globals import COMMAND_TYPE_SERVICE
|
|
6
|
+
from wexample_wex_core.decorator.command import command
|
|
7
|
+
|
|
8
|
+
from wexample_wex_addon_services_db.services.mysql.commands.config.runtime import (
|
|
9
|
+
mysql__config__runtime,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from wexample_wex_addon_app.service.app_service import AppService
|
|
14
|
+
from wexample_wex_core.context.execution_context import ExecutionContext
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@command(type=COMMAND_TYPE_SERVICE, description="Write maria runtime configuration")
|
|
18
|
+
def maria__config__runtime(
|
|
19
|
+
context: ExecutionContext,
|
|
20
|
+
service: AppService,
|
|
21
|
+
) -> None:
|
|
22
|
+
return mysql__config__runtime(context=context, service=service)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from wexample_wex_core.const.globals import COMMAND_TYPE_SERVICE
|
|
6
|
+
from wexample_wex_core.decorator.command import command
|
|
7
|
+
|
|
8
|
+
from wexample_wex_addon_services_db.services.mysql.commands.db.connect import (
|
|
9
|
+
mysql__db__connect,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from wexample_wex_addon_app.service.app_service import AppService
|
|
14
|
+
from wexample_wex_core.context.execution_context import ExecutionContext
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@command(
|
|
18
|
+
type=COMMAND_TYPE_SERVICE, description="Return maria connection arguments string"
|
|
19
|
+
)
|
|
20
|
+
def maria__db__connect(
|
|
21
|
+
context: ExecutionContext,
|
|
22
|
+
service: AppService,
|
|
23
|
+
) -> str:
|
|
24
|
+
return mysql__db__connect(context=context, service=service)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from wexample_wex_core.const.globals import COMMAND_TYPE_SERVICE
|
|
6
|
+
from wexample_wex_core.decorator.command import command
|
|
7
|
+
from wexample_wex_core.decorator.option import option
|
|
8
|
+
|
|
9
|
+
from wexample_wex_addon_services_db.services.mysql.commands.db.destroy import (
|
|
10
|
+
mysql__db__destroy,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from wexample_wex_addon_app.service.app_service import AppService
|
|
15
|
+
from wexample_wex_core.context.execution_context import ExecutionContext
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@option(
|
|
19
|
+
name="database",
|
|
20
|
+
type=str,
|
|
21
|
+
required=False,
|
|
22
|
+
description="Database name (defaults to db.main from runtime config)",
|
|
23
|
+
)
|
|
24
|
+
@command(type=COMMAND_TYPE_SERVICE, description="Drop and recreate the maria database")
|
|
25
|
+
def maria__db__destroy(
|
|
26
|
+
context: ExecutionContext,
|
|
27
|
+
service: AppService,
|
|
28
|
+
database: str | None = None,
|
|
29
|
+
) -> None:
|
|
30
|
+
return mysql__db__destroy(context=context, service=service, database=database)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from wexample_wex_core.const.globals import COMMAND_TYPE_SERVICE
|
|
6
|
+
from wexample_wex_core.decorator.command import command
|
|
7
|
+
from wexample_wex_core.decorator.option import option
|
|
8
|
+
|
|
9
|
+
from wexample_wex_addon_services_db.services.mysql.commands.db.dump import (
|
|
10
|
+
mysql__db__dump,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from wexample_wex_addon_app.service.app_service import AppService
|
|
15
|
+
from wexample_wex_core.context.execution_context import ExecutionContext
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@option(
|
|
19
|
+
name="file_name",
|
|
20
|
+
type=str,
|
|
21
|
+
required=True,
|
|
22
|
+
description="Dump file name (without extension)",
|
|
23
|
+
)
|
|
24
|
+
@command(
|
|
25
|
+
type=COMMAND_TYPE_SERVICE, description="Dump the maria database to a .sql file"
|
|
26
|
+
)
|
|
27
|
+
def maria__db__dump(
|
|
28
|
+
context: ExecutionContext,
|
|
29
|
+
service: AppService,
|
|
30
|
+
file_name: str,
|
|
31
|
+
) -> str:
|
|
32
|
+
return mysql__db__dump(context=context, service=service, file_name=file_name)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from wexample_wex_core.const.globals import COMMAND_TYPE_SERVICE
|
|
6
|
+
from wexample_wex_core.decorator.command import command
|
|
7
|
+
from wexample_wex_core.decorator.option import option
|
|
8
|
+
|
|
9
|
+
from wexample_wex_addon_services_db.services.mysql.commands.db.dumps_list import (
|
|
10
|
+
mysql__db__dumps_list,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from wexample_wex_addon_app.service.app_service import AppService
|
|
15
|
+
from wexample_wex_core.context.execution_context import ExecutionContext
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@option(
|
|
19
|
+
name="database",
|
|
20
|
+
short_name="d",
|
|
21
|
+
type=str,
|
|
22
|
+
required=False,
|
|
23
|
+
description="Database name (unused, reserved for future multi-db support)",
|
|
24
|
+
)
|
|
25
|
+
@command(type=COMMAND_TYPE_SERVICE, description="List available maria dump files")
|
|
26
|
+
def maria__db__dumps_list(
|
|
27
|
+
context: ExecutionContext,
|
|
28
|
+
service: AppService,
|
|
29
|
+
database: str | None = None,
|
|
30
|
+
) -> list[str]:
|
|
31
|
+
return mysql__db__dumps_list(context=context, service=service, database=database)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from wexample_wex_core.const.globals import COMMAND_TYPE_SERVICE
|
|
6
|
+
from wexample_wex_core.decorator.command import command
|
|
7
|
+
from wexample_wex_core.decorator.option import option
|
|
8
|
+
|
|
9
|
+
from wexample_wex_addon_services_db.services.mysql.commands.db.exec import (
|
|
10
|
+
mysql__db__exec,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from wexample_app.response.abstract_response import AbstractResponse
|
|
15
|
+
from wexample_wex_addon_app.service.app_service import AppService
|
|
16
|
+
from wexample_wex_core.context.execution_context import ExecutionContext
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@option(
|
|
20
|
+
name="sql",
|
|
21
|
+
type=str,
|
|
22
|
+
required=True,
|
|
23
|
+
description="SQL command to execute",
|
|
24
|
+
)
|
|
25
|
+
@command(type=COMMAND_TYPE_SERVICE, description="Execute a SQL command in maria")
|
|
26
|
+
def maria__db__exec(
|
|
27
|
+
context: ExecutionContext,
|
|
28
|
+
service: AppService,
|
|
29
|
+
sql: str,
|
|
30
|
+
) -> AbstractResponse:
|
|
31
|
+
return mysql__db__exec(context=context, service=service, sql=sql)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from wexample_wex_core.const.globals import COMMAND_TYPE_SERVICE
|
|
6
|
+
from wexample_wex_core.decorator.command import command
|
|
7
|
+
|
|
8
|
+
from wexample_wex_addon_services_db.services.mysql.commands.db.go import mysql__db__go
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from wexample_app.response.abstract_response import AbstractResponse
|
|
12
|
+
from wexample_wex_addon_app.service.app_service import AppService
|
|
13
|
+
from wexample_wex_core.context.execution_context import ExecutionContext
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@command(
|
|
17
|
+
type=COMMAND_TYPE_SERVICE,
|
|
18
|
+
description="Open an interactive MariaDB CLI in the container",
|
|
19
|
+
)
|
|
20
|
+
def maria__db__go(
|
|
21
|
+
context: ExecutionContext,
|
|
22
|
+
service: AppService,
|
|
23
|
+
) -> AbstractResponse:
|
|
24
|
+
return mysql__db__go(context=context, service=service)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from wexample_wex_core.const.globals import COMMAND_TYPE_SERVICE
|
|
6
|
+
from wexample_wex_core.decorator.command import command
|
|
7
|
+
from wexample_wex_core.decorator.option import option
|
|
8
|
+
|
|
9
|
+
from wexample_wex_addon_services_db.services.mysql.commands.db.restore import (
|
|
10
|
+
mysql__db__restore,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from wexample_wex_addon_app.service.app_service import AppService
|
|
15
|
+
from wexample_wex_core.context.execution_context import ExecutionContext
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@option(
|
|
19
|
+
name="file_name",
|
|
20
|
+
type=str,
|
|
21
|
+
required=True,
|
|
22
|
+
description="SQL dump file name (without path, must be in /var/www/dumps/)",
|
|
23
|
+
)
|
|
24
|
+
@option(
|
|
25
|
+
name="database",
|
|
26
|
+
type=str,
|
|
27
|
+
required=False,
|
|
28
|
+
description="Database name (defaults to db.main from runtime config)",
|
|
29
|
+
)
|
|
30
|
+
@command(
|
|
31
|
+
type=COMMAND_TYPE_SERVICE, description="Restore a maria database from a .sql dump"
|
|
32
|
+
)
|
|
33
|
+
def maria__db__restore(
|
|
34
|
+
context: ExecutionContext,
|
|
35
|
+
service: AppService,
|
|
36
|
+
file_name: str,
|
|
37
|
+
database: str | None = None,
|
|
38
|
+
) -> None:
|
|
39
|
+
return mysql__db__restore(
|
|
40
|
+
context=context,
|
|
41
|
+
service=service,
|
|
42
|
+
file_name=file_name,
|
|
43
|
+
database=database,
|
|
44
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from wexample_wex_core.const.globals import COMMAND_TYPE_SERVICE
|
|
6
|
+
from wexample_wex_core.decorator.command import command
|
|
7
|
+
|
|
8
|
+
from wexample_wex_addon_services_db.services.mysql.commands.service.install import (
|
|
9
|
+
mysql__service__install,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from wexample_wex_addon_app.service.app_service import AppService
|
|
14
|
+
from wexample_wex_core.context.execution_context import ExecutionContext
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@command(
|
|
18
|
+
type=COMMAND_TYPE_SERVICE,
|
|
19
|
+
description="Configure maria service in app config",
|
|
20
|
+
)
|
|
21
|
+
def maria__service__install(
|
|
22
|
+
context: ExecutionContext,
|
|
23
|
+
service: AppService,
|
|
24
|
+
) -> None:
|
|
25
|
+
return mysql__service__install(context=context, service=service)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from wexample_wex_core.const.globals import COMMAND_TYPE_SERVICE
|
|
6
|
+
from wexample_wex_core.decorator.command import command
|
|
7
|
+
|
|
8
|
+
from wexample_wex_addon_services_db.services.mysql.commands.service.ready import (
|
|
9
|
+
mysql__service__ready,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from wexample_app.response.boolean_response import BooleanResponse
|
|
14
|
+
from wexample_wex_addon_app.service.app_service import AppService
|
|
15
|
+
from wexample_wex_core.context.execution_context import ExecutionContext
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@command(type=COMMAND_TYPE_SERVICE, description="Check if maria service is ready")
|
|
19
|
+
def maria__service__ready(
|
|
20
|
+
context: ExecutionContext,
|
|
21
|
+
service: AppService,
|
|
22
|
+
) -> BooleanResponse:
|
|
23
|
+
return mysql__service__ready(context=context, service=service)
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
services:
|
|
2
|
+
maria:
|
|
3
|
+
container_name: ${APP_PROJECT_NAME}_maria
|
|
4
|
+
image: mariadb:10.9
|
|
5
|
+
environment:
|
|
6
|
+
- MYSQL_ROOT_HOST=%
|
|
7
|
+
- MYSQL_PASSWORD=${SERVICE_MARIA_PASSWORD}
|
|
8
|
+
- MYSQL_DATABASE=${SERVICE_MARIA_NAME}
|
|
9
|
+
- MYSQL_ROOT_PASSWORD=${SERVICE_MARIA_PASSWORD}
|
|
10
|
+
- MYSQL_USER=${SERVICE_MARIA_USER}
|
|
11
|
+
volumes:
|
|
12
|
+
- ${APP_SETUP_PATH}maria/data:/var/lib/mysql
|
|
13
|
+
- ${APP_SETUP_PATH}maria/dumps:/var/www/dumps
|
|
14
|
+
- ${APP_SETUP_PATH}tmp/mysql.cnf:/tmp/mysql.cnf
|
|
15
|
+
ports:
|
|
16
|
+
- ${SERVICE_MARIA_PORT}:3306
|
|
17
|
+
networks:
|
|
18
|
+
- wex_net
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from wexample_wex_addon_app.service.app_service import AppService as BaseAppService
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AppService(BaseAppService):
|
|
7
|
+
def get_workdir_contribution(self) -> dict:
|
|
8
|
+
from wexample_filestate.const.disk import DiskItemType
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
"children": [
|
|
12
|
+
{
|
|
13
|
+
"name": "logs",
|
|
14
|
+
"type": DiskItemType.DIRECTORY,
|
|
15
|
+
"should_exist": True,
|
|
16
|
+
"mode": {
|
|
17
|
+
"owner": "999:999",
|
|
18
|
+
"permissions": "750",
|
|
19
|
+
"recursive": True,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "mongo-keyfile",
|
|
24
|
+
"type": DiskItemType.FILE,
|
|
25
|
+
"should_exist": True,
|
|
26
|
+
"mode": {
|
|
27
|
+
"owner": "999:999",
|
|
28
|
+
"permissions": "400",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
]
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from wexample_wex_core.const.globals import COMMAND_TYPE_SERVICE
|
|
6
|
+
from wexample_wex_core.decorator.command import command
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from wexample_wex_addon_app.service.app_service import AppService
|
|
10
|
+
from wexample_wex_core.context.execution_context import ExecutionContext
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@command(type=COMMAND_TYPE_SERVICE, description="Write mongo runtime configuration")
|
|
14
|
+
def mongo__config__runtime(
|
|
15
|
+
context: ExecutionContext,
|
|
16
|
+
service: AppService,
|
|
17
|
+
) -> None:
|
|
18
|
+
from wexample_config.config_value.nested_config_value import NestedConfigValue
|
|
19
|
+
from wexample_helpers.helpers.dict import dict_merge
|
|
20
|
+
|
|
21
|
+
config = service.app_workdir.get_config()
|
|
22
|
+
db_name = config.search(f"service.{service.name}.name").get_str_or_default(
|
|
23
|
+
service.name
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
base = service.app_workdir.build_runtime_config_value().to_dict()
|
|
27
|
+
merged = dict_merge(base, {"db": {"main": db_name}})
|
|
28
|
+
service.app_workdir.get_runtime_config_file().write_config(
|
|
29
|
+
NestedConfigValue(raw=merged)
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
context.io.log(f"mongo config/runtime: written (db.main={db_name})")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|