orztv commited on
Commit
aa0785d
·
1 Parent(s): e5d67eb
Files changed (2) hide show
  1. Dockerfile +4 -0
  2. run.sh +43 -3
Dockerfile CHANGED
@@ -64,6 +64,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
64
  && tar xvf qdrant.tar.gz \
65
  && mv qdrant /usr/local/bin/ \
66
  && rm qdrant.tar.gz \
 
 
 
 
67
  # 清理
68
  && apt-get clean \
69
  && rm -rf /var/lib/apt/lists/* \
 
64
  && tar xvf qdrant.tar.gz \
65
  && mv qdrant /usr/local/bin/ \
66
  && rm qdrant.tar.gz \
67
+ # 创建 Qdrant 配置目录和数据目录
68
+ && mkdir -p /home/pn/.n8n/qdrant/storage \
69
+ && mkdir -p /home/pn/.n8n/qdrant/config \
70
+ && chown -R pn:pn /home/pn/.n8n/qdrant \
71
  # 清理
72
  && apt-get clean \
73
  && rm -rf /var/lib/apt/lists/* \
run.sh CHANGED
@@ -60,8 +60,26 @@ start_redis() {
60
  # 启动 Qdrant 服务
61
  start_qdrant() {
62
  echo "Starting Qdrant server..."
63
- mkdir -p /home/pn/.n8n/qdrant
64
- qdrant > /home/pn/.n8n/qdrant/qdrant.log 2>&1 &
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  # 等待 Qdrant 启动
67
  local timeout=30
@@ -70,12 +88,24 @@ start_qdrant() {
70
  while [ $SECONDS -lt $end ]; do
71
  if curl -s http://localhost:6333/health >/dev/null; then
72
  echo "Qdrant server started successfully"
 
 
 
73
  return 0
74
  fi
 
75
  sleep 1
 
 
 
 
 
 
76
  done
77
 
78
  echo "Failed to start Qdrant server"
 
 
79
  exit 1
80
  }
81
 
@@ -93,7 +123,17 @@ check_services() {
93
 
94
  # 检查 Qdrant
95
  echo "Qdrant 状态:"
96
- curl -s http://localhost:6333/metrics
 
 
 
 
 
 
 
 
 
 
97
  }
98
 
99
  # 主流程
 
60
  # 启动 Qdrant 服务
61
  start_qdrant() {
62
  echo "Starting Qdrant server..."
63
+
64
+ # 确保目录存在并有正确的权限
65
+ mkdir -p /home/pn/.n8n/qdrant/storage
66
+ mkdir -p /home/pn/.n8n/qdrant/config
67
+
68
+ # 创建 Qdrant 配置文件
69
+ cat > /home/pn/.n8n/qdrant/config/config.yaml <<EOF
70
+ service:
71
+ host: 0.0.0.0
72
+ port: 6333
73
+ grpc_port: 6334
74
+
75
+ storage:
76
+ storage_path: /home/pn/.n8n/qdrant/storage
77
+
78
+ log_level: INFO
79
+ EOF
80
+
81
+ # 使用配置文件启动 Qdrant
82
+ qdrant --config /home/pn/.n8n/qdrant/config/config.yaml > /home/pn/.n8n/qdrant/qdrant.log 2>&1 &
83
 
84
  # 等待 Qdrant 启动
85
  local timeout=30
 
88
  while [ $SECONDS -lt $end ]; do
89
  if curl -s http://localhost:6333/health >/dev/null; then
90
  echo "Qdrant server started successfully"
91
+ # 输出版本信息
92
+ echo "Qdrant version:"
93
+ curl -s http://localhost:6333/version
94
  return 0
95
  fi
96
+ echo "Waiting for Qdrant to start..."
97
  sleep 1
98
+
99
+ # 检查是否有错误日志
100
+ if grep -i "error" /home/pn/.n8n/qdrant/qdrant.log >/dev/null 2>&1; then
101
+ echo "Error found in Qdrant logs:"
102
+ tail -n 10 /home/pn/.n8n/qdrant/qdrant.log
103
+ fi
104
  done
105
 
106
  echo "Failed to start Qdrant server"
107
+ echo "Last 10 lines of Qdrant log:"
108
+ tail -n 10 /home/pn/.n8n/qdrant/qdrant.log
109
  exit 1
110
  }
111
 
 
123
 
124
  # 检查 Qdrant
125
  echo "Qdrant 状态:"
126
+ if curl -s http://localhost:6333/metrics >/dev/null; then
127
+ echo "Qdrant 运行正常"
128
+ curl -s http://localhost:6333/metrics
129
+
130
+ # 显示集合信息
131
+ echo "Qdrant 集合列表:"
132
+ curl -s http://localhost:6333/collections
133
+ else
134
+ echo "Qdrant 服务异常"
135
+ tail -n 10 /home/pn/.n8n/qdrant/qdrant.log
136
+ fi
137
  }
138
 
139
  # 主流程