Skip to content

Commit c9fe0e2

Browse files
committed
feat: update MindsDB URL handling and improve seeding process in Makefile
1 parent 1c4031a commit c9fe0e2

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

apps/server/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { runMindsDBQuery } from "./lib/minds";
1212

1313
config();
1414

15+
export const mindsDBUrl = process.env.MINDSDB_URL || "http://localhost:47334";
16+
1517
const app = new Hono<{
1618
Variables: {
1719
user: typeof authClient.$Infer.Session.user | null;

apps/server/src/lib/minds.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { MindsDBConfig } from "@kbnet/shared";
22
import { sanitizeSQLValue } from "./util";
3-
4-
const mindsDBUrl = process.env.MINDSDB_URL || "http://localhost:47334";
3+
import { mindsDBUrl } from "..";
54

65
export async function runMindsDBQuery(query: string) {
76
try {

self-host/Makefile

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ check-node:
5050

5151
start-docker:
5252
@echo "🚀 Starting Docker services..."
53-
docker-compose -f $(DOCKER_COMPOSE) up -d
53+
docker compose -f $(DOCKER_COMPOSE) up -d
5454
@echo "⌛ Waiting for API to become available..."
5555
@sleep 5
5656

@@ -89,15 +89,24 @@ done:
8989

9090

9191
seed:
92-
@echo "🌱 Seeding the MindsDB..."
93-
@echo "🔑 Loading environment variables..."
94-
@if [ -f .env ]; then \
95-
echo "📋 Copying .env file to seed directory..."; \
96-
cp .env $(SEED_DIR)/.env && \
97-
cd $(SEED_DIR) && npm install && npm run seed && rm -f .env; \
92+
@echo "🔍 Checking MindsDB is online"
93+
@curl -s --fail $(API_URL) | jq '.' || (echo "❌ MindsDB is not online"; exit 1)
94+
@if curl -s $(API_URL) | grep -q '"mindsDB":"connected"'; then \
95+
echo "✅ MindsDB is connected. proceeding with seeding."; \
96+
echo "🌱 Seeding the MindsDB..."; \
97+
echo "🔑 Loading environment variables..."; \
98+
if [ -f .env ]; then \
99+
echo "📋 Copying .env file to seed directory..."; \
100+
cp .env $(SEED_DIR)/.env && \
101+
cd $(SEED_DIR) && npm install && npm run seed && rm -f .env; \
102+
else \
103+
echo "⚠️ No .env file found, proceeding without environment variables"; \
104+
cd $(SEED_DIR) && npm install && npm run seed; \
105+
fi; \
106+
if [ $$? -ne 0 ]; then echo "❌ Seeding failed"; exit 1; fi; \
107+
echo "✅ MindsDB seeded successfully."; \
98108
else \
99-
echo "⚠️ No .env file found, proceeding without environment variables"; \
100-
cd $(SEED_DIR) && npm install && npm run seed; \
101-
fi
102-
@if [ $$? -ne 0 ]; then echo "❌ Seeding failed"; exit 1; fi
103-
@echo "✅ MindsDB seeded successfully."
109+
echo "⚠️ MindsDB is not connected, please wait and try again after some seconds."; \
110+
echo "Run 'make seed' to seed MindsDB."; \
111+
exit 1; \
112+
fi

0 commit comments

Comments
 (0)