@@ -86,47 +86,136 @@ interval=10
86
86
elapsed=0
87
87
88
88
echo " Waiting for MCP service to become healthy..."
89
+ previous_status=" "
90
+ previous_logs=" "
91
+ no_progress_count=0
92
+
89
93
while [ $elapsed -lt $timeout ]; do
90
- # Check if files-db-mcp is healthy and fetch logs to parse model download progress
94
+ # Check if files-db-mcp is healthy
91
95
if [ ! -z " $MCP_CONTAINER " ]; then
92
96
MCP_STATUS=$( docker inspect --format=' {{if .State.Health}}{{.State.Health.Status}}{{else}}no health check{{end}}' " $MCP_CONTAINER " 2> /dev/null || echo " error" )
93
- echo -n " MCP Status: $MCP_STATUS "
94
- echo
95
97
96
- # Check for model downloading in logs
97
- MODEL_DOWNLOAD=$( docker logs --tail 20 " $MCP_CONTAINER " 2>&1 | grep -E " Downloading.*model.*:|Downloading.*model.*%" )
98
- if [ ! -z " $MODEL_DOWNLOAD " ]; then
99
- echo " ==== Model download in progress ===="
100
- docker logs --tail 10 " $MCP_CONTAINER " 2>&1 | grep -E " Downloading.*%|Loading embedding model" | tail -n 3
101
- echo " ==================================="
98
+ # Get the latest logs for analysis
99
+ RECENT_LOGS=$( docker logs --tail 50 " $MCP_CONTAINER " 2>&1 )
100
+
101
+ # Extract key information
102
+ MODEL_DOWNLOAD=$( echo " $RECENT_LOGS " | grep -E " Downloading|Loading embedding model|Progress:" | tail -n 3)
103
+ ERROR_LOGS=$( echo " $RECENT_LOGS " | grep -E " Error|Exception|Failed|WARNING" | tail -n 3)
104
+ INDEXING_PROGRESS=$( echo " $RECENT_LOGS " | grep -E " Indexed|Processing files|file_processor" | tail -n 2)
105
+
106
+ # Only print status if it changed or we have new logs to show
107
+ if [ " $MCP_STATUS " != " $previous_status " ] || [ " $MODEL_DOWNLOAD " != " $previous_logs " ]; then
108
+ # Display a nice timestamp and status
109
+ echo -e " \n[$( date +" %H:%M:%S" ) ] MCP Status: $MCP_STATUS "
110
+
111
+ # Show relevant progress information based on what we find in logs
112
+ if [ ! -z " $MODEL_DOWNLOAD " ]; then
113
+ echo -e " \nπ₯ Model download progress:"
114
+ echo " $MODEL_DOWNLOAD " | sed ' s/^/ /'
115
+ previous_logs=" $MODEL_DOWNLOAD "
116
+ no_progress_count=0
117
+ elif [ ! -z " $INDEXING_PROGRESS " ]; then
118
+ echo -e " \nπ Indexing progress:"
119
+ echo " $INDEXING_PROGRESS " | sed ' s/^/ /'
120
+ previous_logs=" $INDEXING_PROGRESS "
121
+ no_progress_count=0
122
+ elif [ ! -z " $ERROR_LOGS " ]; then
123
+ echo -e " \nβ οΈ Recent issues detected:"
124
+ echo " $ERROR_LOGS " | sed ' s/^/ /'
125
+ previous_logs=" $ERROR_LOGS "
126
+ no_progress_count=0
127
+ else
128
+ # If we have no specific progress to show, but status changed
129
+ if [ " $MCP_STATUS " != " $previous_status " ]; then
130
+ echo " System is initializing..."
131
+ no_progress_count=0
132
+ else
133
+ # Increment the counter if we've shown this before
134
+ no_progress_count=$(( no_progress_count + 1 ))
135
+
136
+ # Every 3 iterations with no change, show a waiting message
137
+ if [ $(( no_progress_count % 3 )) -eq 0 ]; then
138
+ echo " Still working... (elapsed: ${elapsed} s)"
139
+
140
+ # After 60 seconds with no progress, show a more detailed message
141
+ if [ $elapsed -gt 60 ]; then
142
+ echo " Taking longer than expected. For detailed logs run:"
143
+ echo " docker logs $MCP_CONTAINER "
144
+ fi
145
+ fi
146
+ fi
147
+ fi
148
+
149
+ previous_status=" $MCP_STATUS "
102
150
fi
103
151
152
+ # If healthy, we're done
104
153
if [ " $MCP_STATUS " = " healthy" ]; then
105
- echo " MCP service is healthy!"
154
+ echo -e " \nβ
MCP service is healthy!"
106
155
break
107
156
fi
108
157
else
109
- echo " MCP container not found"
158
+ echo " β MCP container not found!"
159
+ sleep 5
160
+ # Try to find the container again
161
+ MCP_CONTAINER=$( docker compose -f " $BASE_DIR /docker-compose.yml" ps -q files-db-mcp)
110
162
fi
111
163
112
164
sleep $interval
113
165
elapsed=$(( elapsed + interval))
114
- # Don't print dots as they're not informative
115
166
done
116
167
117
168
if [ $elapsed -ge $timeout ]; then
118
- echo " Timeout waiting for MCP service to become healthy."
119
- echo " Check MCP container logs with: docker logs $MCP_CONTAINER "
120
- echo " Check Vector DB container logs with: docker logs $VECTOR_DB_CONTAINER "
169
+ echo -e " \nβ±οΈ Timeout waiting for MCP service to become healthy after ${timeout} seconds."
170
+ echo -e " \nπ Diagnostic information:"
171
+
172
+ # Get the latest error logs
173
+ echo -e " \nLast few errors from MCP container:"
174
+ docker logs " $MCP_CONTAINER " 2>&1 | grep -E " ERROR|Error|Exception|Failed" | tail -n 5 | sed ' s/^/ /'
175
+
176
+ echo -e " \nβ οΈ The system failed to initialize properly. This could be due to:"
177
+ echo " β’ Network connectivity issues when downloading models"
178
+ echo " β’ Insufficient disk space for the model cache"
179
+ echo " β’ Incompatible versions of dependencies"
180
+ echo " β’ Memory constraints when loading large models"
181
+
182
+ echo -e " \nπ Troubleshooting steps:"
183
+ echo " 1. Check full container logs:"
184
+ echo " docker logs $MCP_CONTAINER "
185
+ echo " docker logs $VECTOR_DB_CONTAINER "
186
+ echo " 2. Try restarting with:"
187
+ echo " docker compose -f \" $BASE_DIR /docker-compose.yml\" restart"
188
+ echo " 3. Check for disk space issues:"
189
+ echo " df -h"
190
+ echo " 4. For detailed troubleshooting help, see the docs at:"
191
+ echo " https://github.com/randomm/files-db-mcp/blob/main/docs/troubleshooting.md"
192
+
121
193
exit 1
122
194
fi
123
195
124
- echo
125
- echo " Files-DB-MCP is ready!"
126
- echo " Indexing is running in the background."
127
- echo " You can now connect to the MCP interface at http://localhost:3000"
128
- echo
129
- echo " To check indexing status: curl http://localhost:3000/health"
130
- echo " To stop the service: docker compose down"
131
- echo
132
- echo " Services are running in the background. Happy coding!"
196
+ echo -e " \nπ Files-DB-MCP is ready!"
197
+
198
+ # Get indexing status
199
+ HEALTH_INFO=$( curl -s http://localhost:3000/health 2> /dev/null || echo ' {"indexed_files":0,"total_files":0,"indexing_progress":0}' )
200
+ INDEXED_FILES=$( echo $HEALTH_INFO | grep -o ' "indexed_files":[0-9]*' | cut -d' :' -f2)
201
+ TOTAL_FILES=$( echo $HEALTH_INFO | grep -o ' "total_files":[0-9]*' | cut -d' :' -f2)
202
+ PROGRESS=$( echo $HEALTH_INFO | grep -o ' "indexing_progress":[0-9.]*' | cut -d' :' -f2)
203
+
204
+ # Display information about indexing status
205
+ if [ ! -z " $INDEXED_FILES " ] && [ ! -z " $TOTAL_FILES " ] && [ ! -z " $PROGRESS " ]; then
206
+ echo -e " π Indexing status: ${PROGRESS} % complete (${INDEXED_FILES} /${TOTAL_FILES} files)"
207
+ echo -e " Indexing is running in the background and will continue automatically.\n"
208
+ else
209
+ echo -e " π Indexing is running in the background and will continue automatically.\n"
210
+ fi
211
+
212
+ echo -e " π Connection Information:"
213
+ echo -e " MCP interface: http://localhost:3000"
214
+ echo -e " Vector database: localhost:6333\n"
215
+
216
+ echo -e " π Useful commands:"
217
+ echo -e " Check indexing status: curl http://localhost:3000/health"
218
+ echo -e " View logs: docker logs $MCP_CONTAINER "
219
+ echo -e " Stop service: docker compose -f \" $BASE_DIR /docker-compose.yml\" down\n"
220
+
221
+ echo -e " β¨ Services are running in the background. Happy coding!"
0 commit comments