Skip to content

Commit e3fd04f

Browse files
authored
Merge pull request #49 from longbingljw/fix-make-stop
fix: make stop command can't stop db container
2 parents 5edfe28 + a18f7f2 commit e3fd04f

6 files changed

Lines changed: 48 additions & 130 deletions

File tree

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ Notes: If you are participating in the OceanBase AI Workshop, you can skip steps
112112

113113
## Building the Chatbot
114114

115-
### Quick Start with Docker (Recommended)
116-
117-
If you want to quickly deploy the chatbot using Docker, see [Docker Deployment Guide](./docker/README.md).
115+
### Quick Start (Recommended)
118116

119117
```bash
120118
# 1. Configure environment

README_zh.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ RAG 的主要优势有:
112112

113113
## 构建聊天机器人
114114

115-
### Docker 快速启动(推荐)
116-
117-
如果您想使用 Docker 快速部署聊天机器人,请参见 [Docker 部署指南](./docker/README.md)
115+
### 快速启动(推荐)
118116

119117
```bash
120118
# 1. 配置环境变量

docker/README.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

scripts/init_docker.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fi
5151

5252
# Download Docker images based on DB_STORE
5353
if [ "${DB_STORE}" = "seekdb" ]; then
54-
docker_name="seekdb"
54+
docker_name="chatbot-seekdb"
5555
# Check if container already exists
5656
if sudo docker ps -a --format "{{.Names}}" | grep -q "^${docker_name}$"; then
5757
echo "Container '${docker_name}' already exists."
@@ -64,10 +64,10 @@ if [ "${DB_STORE}" = "seekdb" ]; then
6464
else
6565
echo "Downloading latest seekdb docker image..."
6666
export ROOT_PASSWORD=${DB_PASSWORD}
67-
sudo docker run --name seekdb -e ROOT_PASSWORD=${DB_PASSWORD} -d -p 2881:2881 -p 2886:2886 oceanbase/seekdb
67+
sudo docker run --name "${docker_name}" -e ROOT_PASSWORD=${DB_PASSWORD} -d -p 2881:2881 -p 2886:2886 oceanbase/seekdb
6868
fi
6969
elif [ "${DB_STORE}" = "oceanbase" ]; then
70-
docker_name="oceanbase-ce"
70+
docker_name="chatbot-oceanbase"
7171
# Check if container already exists
7272
if sudo docker ps -a --format "{{.Names}}" | grep -q "^${docker_name}$"; then
7373
echo "Container '${docker_name}' already exists."
@@ -80,11 +80,10 @@ elif [ "${DB_STORE}" = "oceanbase" ]; then
8080
else
8181
echo "Downloading latest oceanbase-ce docker image..."
8282
export OB_TENANT_PASSWORD=${DB_PASSWORD}
83-
sudo docker run -p 2881:2881 --name oceanbase-ce -e OB_TENANT_PASSWORD=${DB_PASSWORD} -e datafile_size=10G -d oceanbase/oceanbase-ce
83+
sudo docker run -p 2881:2881 --name "${docker_name}" -e OB_TENANT_PASSWORD=${DB_PASSWORD} -e datafile_size=10G -d oceanbase/oceanbase-ce:4.4.1.0-100010012025120515
8484
fi
8585
else
8686
echo "Warning: Unknown DB_STORE value: ${DB_STORE}. Skipping docker image download."
87-
exit 0
8887
fi
8988

9089
# Wait for download to complete
@@ -129,9 +128,9 @@ if [ "$connection_failed" = true ]; then
129128

130129
# Determine docker_name based on DB_STORE
131130
if [ "${DB_STORE}" = "seekdb" ]; then
132-
docker_name="seekdb"
131+
docker_name="chatbot-seekdb"
133132
elif [ "${DB_STORE}" = "oceanbase" ]; then
134-
docker_name="oceanbase-ce"
133+
docker_name="chatbot-oceanbase"
135134
else
136135
echo "Warning: Unknown DB_STORE value: ${DB_STORE}. Cannot determine docker name."
137136
exit 1

scripts/stop.sh

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,51 @@ echo "Stopping ChatBot UI service..."
1616
# Find and kill streamlit processes running chat_ui.py or flow_ui.py
1717
PIDS=$(ps aux | grep -E "streamlit.*chat_ui\.py|streamlit.*flow_ui\.py" | grep -v grep | awk '{print $2}')
1818

19-
if [ -z "$PIDS" ]; then
19+
if [ -n "$PIDS" ]; then
20+
for PID in $PIDS; do
21+
echo "Stopping process $PID..."
22+
kill "$PID" 2>/dev/null || true
23+
done
24+
25+
# Wait a bit for processes to terminate
26+
sleep 2
27+
28+
# Force kill if still running
29+
PIDS=$(ps aux | grep -E "streamlit.*chat_ui\.py|streamlit.*flow_ui\.py" | grep -v grep | awk '{print $2}')
30+
if [ -n "$PIDS" ]; then
31+
for PID in $PIDS; do
32+
echo "Force stopping process $PID..."
33+
kill -9 "$PID" 2>/dev/null || true
34+
done
35+
fi
36+
else
2037
echo "No ChatBot UI service is running."
21-
exit 0
2238
fi
2339

24-
for PID in $PIDS; do
25-
echo "Stopping process $PID..."
26-
kill "$PID" 2>/dev/null || true
27-
done
40+
# Stop database container only when local DB is managed by make init
41+
if [ -f "$PROJECT_ROOT/.env" ]; then
42+
set -a
43+
source "$PROJECT_ROOT/.env"
44+
set +a
2845

29-
# Wait a bit for processes to terminate
30-
sleep 2
46+
if [ "${REUSE_CURRENT_DB}" != "true" ]; then
47+
docker_name=""
48+
if [ "${DB_STORE}" = "seekdb" ]; then
49+
docker_name="chatbot-seekdb"
50+
elif [ "${DB_STORE}" = "oceanbase" ]; then
51+
docker_name="chatbot-oceanbase"
52+
fi
3153

32-
# Force kill if still running
33-
PIDS=$(ps aux | grep -E "streamlit.*chat_ui\.py|streamlit.*flow_ui\.py" | grep -v grep | awk '{print $2}')
34-
if [ -n "$PIDS" ]; then
35-
for PID in $PIDS; do
36-
echo "Force stopping process $PID..."
37-
kill -9 "$PID" 2>/dev/null || true
38-
done
54+
if [ -n "$docker_name" ] && command -v docker &> /dev/null; then
55+
if docker ps --format "{{.Names}}" 2>/dev/null | grep -q "^${docker_name}$"; then
56+
echo "Stopping docker container ${docker_name}..."
57+
docker stop "${docker_name}" >/dev/null || true
58+
elif sudo docker ps --format "{{.Names}}" 2>/dev/null | grep -q "^${docker_name}$"; then
59+
echo "Stopping docker container (sudo) ${docker_name}..."
60+
sudo docker stop "${docker_name}" >/dev/null || true
61+
fi
62+
fi
63+
fi
3964
fi
4065

4166
echo "ChatBot UI service stopped."

src/common/db.py

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"""
1111
import re
1212
import sys
13-
import warnings
1413
from dataclasses import dataclass
1514
from typing import Optional
1615

@@ -353,83 +352,6 @@ def create_pyseekdb_client(params: Optional[ConnectionParams] = None): # type:
353352
return client
354353

355354

356-
# Default values for deprecated vector memory parameters
357-
_DEFAULT_VECTOR_MEMORY_LIMIT_PERCENTAGE = 30
358-
_DEFAULT_QUERY_TIMEOUT = 100000000
359-
360-
361-
def ensure_vector_memory_params(
362-
client, # pyseekdb.Client - type ignored due to library typing issues
363-
memory_limit_percentage: int = _DEFAULT_VECTOR_MEMORY_LIMIT_PERCENTAGE,
364-
query_timeout: int = _DEFAULT_QUERY_TIMEOUT,
365-
) -> None:
366-
"""
367-
Ensure vector memory parameters are properly configured.
368-
369-
.. deprecated::
370-
This function is deprecated and will be removed in a future version.
371-
Database parameters should be configured at the infrastructure level,
372-
not in application code.
373-
374-
Checks and sets the ob_vector_memory_limit_percentage parameter if needed,
375-
and sets the ob_query_timeout for the session.
376-
377-
Args:
378-
client: pyseekdb client instance
379-
memory_limit_percentage: Target value for ob_vector_memory_limit_percentage
380-
query_timeout: Query timeout in microseconds
381-
382-
Raises:
383-
RuntimeError: If parameter check or setting fails
384-
"""
385-
warnings.warn(
386-
"ensure_vector_memory_params is deprecated and will be removed in a future version. "
387-
"Database parameters should be configured at the infrastructure level.",
388-
DeprecationWarning,
389-
stacklevel=2,
390-
)
391-
392-
logger.info("Checking and setting database parameters")
393-
394-
# Check ob_vector_memory_limit_percentage
395-
vals = []
396-
params = client.execute(
397-
"SHOW PARAMETERS LIKE '%ob_vector_memory_limit_percentage%'"
398-
)
399-
for row in params:
400-
val = int(row[6])
401-
vals.append(val)
402-
403-
if len(vals) == 0:
404-
logger.error("ob_vector_memory_limit_percentage not found in parameters.")
405-
raise RuntimeError("ob_vector_memory_limit_percentage not found in parameters.")
406-
407-
# Set ob_vector_memory_limit_percentage if any value is 0
408-
if any(val == 0 for val in vals):
409-
try:
410-
logger.info(
411-
f"Setting ob_vector_memory_limit_percentage to {memory_limit_percentage}"
412-
)
413-
client.execute(
414-
f"ALTER SYSTEM SET ob_vector_memory_limit_percentage = {memory_limit_percentage}"
415-
)
416-
logger.info(
417-
f"Successfully set ob_vector_memory_limit_percentage to {memory_limit_percentage}"
418-
)
419-
except Exception as e:
420-
logger.error(
421-
f"Failed to set ob_vector_memory_limit_percentage to {memory_limit_percentage}: {e}"
422-
)
423-
raise RuntimeError(
424-
f"Failed to set ob_vector_memory_limit_percentage: {e}"
425-
) from e
426-
427-
# Set query timeout
428-
logger.info(f"Setting ob_query_timeout to {query_timeout}")
429-
client.execute(f"SET ob_query_timeout={query_timeout}")
430-
logger.debug("Database parameters configured successfully")
431-
432-
433355
# =============================================================================
434356
# CLI Functions
435357
# =============================================================================

0 commit comments

Comments
 (0)