feat(manager): update port change utility to return detailed proxy info
This commit is contained in:
@@ -9,7 +9,7 @@ async def create_proxy(
|
|||||||
port: int,
|
port: int,
|
||||||
service: DockerContainer,
|
service: DockerContainer,
|
||||||
code: str,
|
code: str,
|
||||||
) -> int:
|
) -> dict[str, object]:
|
||||||
"""
|
"""
|
||||||
Utility function that will:
|
Utility function that will:
|
||||||
- run ``integrations/docker`` utilities to change the old port of original service to a random one
|
- run ``integrations/docker`` utilities to change the old port of original service to a random one
|
||||||
@@ -17,7 +17,7 @@ async def create_proxy(
|
|||||||
- start a subprocess via asyncio
|
- start a subprocess via asyncio
|
||||||
- return the proxy infos (pid, )
|
- return the proxy infos (pid, )
|
||||||
"""
|
"""
|
||||||
path = Path(f"/tmp/theplug/{service["name"]}.py")
|
path = Path(f"/tmp/theplug/{service['name']}.py")
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
path.write_text(code, encoding="utf-8")
|
path.write_text(code, encoding="utf-8")
|
||||||
@@ -26,12 +26,17 @@ async def create_proxy(
|
|||||||
# scegliere una porta random alla quale spostare il docker
|
# scegliere una porta random alla quale spostare il docker
|
||||||
# modificare il docker via integrations.docker.editor.change_port ( service.folder, service.name, port, random_nuova_port )
|
# modificare il docker via integrations.docker.editor.change_port ( service.folder, service.name, port, random_nuova_port )
|
||||||
random_port = _get_random_port()
|
random_port = _get_random_port()
|
||||||
docker.editor.change_port(
|
changed = await docker.change_port(
|
||||||
service["name"],
|
service["name"],
|
||||||
service["folder"],
|
service["folder"],
|
||||||
port,
|
port,
|
||||||
random_port,
|
random_port,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
return 0
|
"service": service["name"],
|
||||||
|
"previous_port": port,
|
||||||
|
"upstream_port": random_port,
|
||||||
|
"script_path": str(path),
|
||||||
|
"port_changed": changed,
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user