-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathredeploy_containers.py
More file actions
107 lines (79 loc) · 2.23 KB
/
redeploy_containers.py
File metadata and controls
107 lines (79 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import subprocess
import os
import json
import time
import signal
import asyncpg
import asyncio
import platform
import qdrant_client
from qdrant_client.models import VectorParams, Distance
import docker
# Get the docker client
docker_client = docker.from_env()
# ==============================================================
# Start the PostgreSQL server
# ==============================================================
postgres_name = "dev-postgres"
# Check if the postgres container exists
postgres_exists = (
len(docker_client.containers.list(filters={"name": postgres_name})) > 0
)
# Stop any container that exists
subprocess.run(["docker", "stop", postgres_name])
# Remove it from docker
subprocess.run(["docker", "rm", postgres_name])
postgres_stopped = False
# Run the container
# Start the PostgreSQL server
print("Starting new postgres container...")
postgres_process = subprocess.run(
[
"docker",
"run",
"--name",
postgres_name,
"-e",
"POSTGRES_PASSWORD=postgres",
"-p",
"5432:5432",
"-d",
"postgres",
],
)
time.sleep(2)
from setup import setup_postgres
# Add the embeddings collection if they've been restarted
asyncio.run(setup_postgres())
# ==============================================================
# Start the qdrant server
# ==============================================================
qdrant_name = "dev-qdrant"
# Check if the qdrant container exists
qdrant_exists = len(docker_client.containers.list(filters={"name": "dev-qdrant"})) > 0
# Stop any container that exists
subprocess.run(["docker", "stop", qdrant_name])
# Remove it from docker
subprocess.run(["docker", "rm", qdrant_name])
qdrant_stopeed = False
# Run the container
# Start the server in docker
qdrant_process = subprocess.run(
[
"docker",
"run",
"--name",
qdrant_name,
"-p",
"6333:6333",
"-d",
"qdrant/qdrant",
],
)
qdrant = qdrant_client.QdrantClient(host="localhost", port=6333)
time.sleep(2)
# Check the qdrant container exists
qdrant_exists = len(docker_client.containers.list(filters={"name": qdrant_name})) > 0
from setup import setup_qdrant
asyncio.run(setup_qdrant(qdrant))
time.sleep(2)