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,
|
||||
service: DockerContainer,
|
||||
code: str,
|
||||
) -> int:
|
||||
) -> dict[str, object]:
|
||||
"""
|
||||
Utility function that will:
|
||||
- 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
|
||||
- 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.write_text(code, encoding="utf-8")
|
||||
@@ -26,12 +26,17 @@ async def create_proxy(
|
||||
# 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 )
|
||||
random_port = _get_random_port()
|
||||
docker.editor.change_port(
|
||||
changed = await docker.change_port(
|
||||
service["name"],
|
||||
service["folder"],
|
||||
port,
|
||||
random_port,
|
||||
)
|
||||
|
||||
|
||||
return 0
|
||||
return {
|
||||
"service": service["name"],
|
||||
"previous_port": port,
|
||||
"upstream_port": random_port,
|
||||
"script_path": str(path),
|
||||
"port_changed": changed,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user