Skip to content

Commit 028b426

Browse files
committed
more startup.md fixes
1 parent 725c4d5 commit 028b426

2 files changed

Lines changed: 141 additions & 11 deletions

File tree

embabel-hub/STARTUP.md

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,77 @@
1-
Frontend: http://localhost:8042
2-
Neo4j Browser: http://localhost:27474
3-
(connect to bolt://localhost:27687, username: neo4j, password: embabel123)
4-
Guide API: http://localhost:1337l
1+
# Embabel Hub Startup Guide
2+
3+
## Prerequisites
4+
5+
- Docker installed and running
6+
- `OPENAI_API_KEY` environment variable set (see configuration below)
7+
8+
## Configuration
9+
10+
The `starthub.sh` script automatically sources environment variables from a `.env` file if present.
11+
12+
### Option 1: Using a .env file (Recommended)
13+
14+
Create a `.env` file in either:
15+
16+
- `embabel-hub/.env` (preferred, most specific)
17+
- `embabel-learning/.env` (parent directory, fallback)
18+
19+
Add your OpenAI API key:
20+
21+
```bash
22+
OPENAI_API_KEY=your-api-key-here
23+
```
24+
25+
The script will automatically load this file when run.
26+
27+
### Option 2: Export environment variable
28+
29+
```bash
30+
export OPENAI_API_KEY=your-api-key-here
31+
```
32+
33+
### Option 3: Pass inline
34+
35+
```bash
36+
OPENAI_API_KEY=your-api-key-here ./embabel-hub/starthub.sh
37+
```
38+
39+
## Starting the Hub
40+
41+
Simply run:
42+
43+
```bash
44+
./embabel-hub/starthub.sh
45+
```
46+
47+
The script will:
48+
49+
1. Load environment variables from `.env` if present
50+
2. Stop and remove any existing container
51+
3. Start a new embabel-hub container
52+
4. Wait for the application to start (30-60 seconds)
53+
5. Verify the web server is responding
54+
55+
## Services
56+
57+
Once started, the following services are available:
58+
59+
- **Guide API**: http://localhost:1337
60+
- **Neo4j Browser**: http://localhost:27474
61+
- **Neo4j Bolt**: bolt://localhost:27687
62+
- Username: `neo4j`
63+
- Password: See container documentation (default: `embabel123` for local dev)
64+
- **Frontend**: http://localhost:8042
65+
66+
## Troubleshooting
67+
68+
If the web server doesn't start, check the logs:
69+
70+
```bash
71+
docker logs embabel-hub
72+
```
73+
74+
Common issues:
75+
76+
- **401 Unauthorized**: Invalid or expired `OPENAI_API_KEY`
77+
- **Application startup timeout**: Check logs for initialization errors

embabel-hub/starthub.sh

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
#!/bin/bash
22
# Start embabel-hub container
3-
# Requires: OPENAI_API_KEY environment variable
3+
# Requires: OPENAI_API_KEY environment variable (can be set in .env file or environment)
44

5+
# Get the directory where this script is located
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
PARENT_DIR="$(dirname "$SCRIPT_DIR")"
8+
9+
# Source .env file if it exists (prefer local .env, then parent directory .env)
10+
if [ -f "$SCRIPT_DIR/.env" ]; then
11+
echo "Loading environment from $SCRIPT_DIR/.env"
12+
set -a # automatically export all variables
13+
source "$SCRIPT_DIR/.env"
14+
set +a # disable automatic export
15+
elif [ -f "$PARENT_DIR/.env" ]; then
16+
echo "Loading environment from $PARENT_DIR/.env"
17+
set -a # automatically export all variables
18+
source "$PARENT_DIR/.env"
19+
set +a # disable automatic export
20+
fi
21+
22+
# Check if OPENAI_API_KEY is set
523
if [ -z "$OPENAI_API_KEY" ]; then
624
echo "Error: OPENAI_API_KEY environment variable is not set"
7-
echo "Usage: OPENAI_API_KEY=your-key-here ./starthub.sh"
25+
echo ""
26+
echo "You can set it in one of these ways:"
27+
echo " 1. Create a .env file in embabel-hub/ or parent directory with: OPENAI_API_KEY=your-key-here"
28+
echo " 2. Export it: export OPENAI_API_KEY=your-key-here"
29+
echo " 3. Pass it inline: OPENAI_API_KEY=your-key-here ./starthub.sh"
830
exit 1
931
fi
1032

@@ -17,6 +39,7 @@ if docker ps -a --format '{{.Names}}' | grep -q "^embabel-hub$"; then
1739
fi
1840

1941
echo "Starting new embabel-hub container..."
42+
# pragma: allowlist secret
2043
docker run -d \
2144
--platform linux/amd64 \
2245
--name embabel-hub \
@@ -26,16 +49,50 @@ docker run -d \
2649
-p 8042:8042 \
2750
-v embabel-neo4j-data:/data \
2851
-v embabel-neo4j-logs:/logs \
29-
-e OPENAI_API_KEY=$OPENAI_API_KEY \
52+
-e "OPENAI_API_KEY=$OPENAI_API_KEY" \
3053
embabel/hub:latest
3154

3255
if [ $? -eq 0 ]; then
3356
echo "✓ embabel-hub container started successfully"
3457
echo ""
35-
echo "Hub: http://localhost:1337"
36-
echo "Neo4j Browser: http://localhost:27474"
37-
echo "Neo4j Bolt: bolt://localhost:27687"
38-
echo "Additional service: http://localhost:8042"
58+
echo "Waiting for application to start (this may take 30-60 seconds)..."
59+
60+
# Wait up to 60 seconds for the web server to respond
61+
max_wait=60
62+
elapsed=0
63+
while [ $elapsed -lt $max_wait ]; do
64+
if curl -s -f http://localhost:1337 > /dev/null 2>&1; then
65+
echo "✓ Web server is responding!"
66+
break
67+
fi
68+
sleep 2
69+
elapsed=$((elapsed + 2))
70+
echo " Waiting... (${elapsed}s/${max_wait}s)"
71+
done
72+
73+
# Check if server is responding
74+
if curl -s -f http://localhost:1337 > /dev/null 2>&1; then
75+
echo ""
76+
echo "Hub: http://localhost:1337"
77+
echo "Neo4j Browser: http://localhost:27474"
78+
echo "Neo4j Bolt: bolt://localhost:27687"
79+
echo "Additional service: http://localhost:8042"
80+
else
81+
echo ""
82+
echo "⚠ Warning: Container started but web server is not responding"
83+
echo ""
84+
echo "Checking container logs for errors..."
85+
echo "Recent errors:"
86+
docker logs embabel-hub 2>&1 | grep -i "error\|exception\|401\|unauthorized" | tail -5 || echo "No obvious errors found"
87+
echo ""
88+
echo "To view full logs: docker logs embabel-hub"
89+
echo "To check container status: docker ps -a | grep embabel-hub"
90+
echo ""
91+
echo "Common issues:"
92+
echo " - Invalid or expired OPENAI_API_KEY (check for 401 errors in logs)"
93+
echo " - Application startup timeout (check logs for startup errors)"
94+
exit 1
95+
fi
3996
else
4097
echo "✗ Failed to start embabel-hub container"
4198
exit 1

0 commit comments

Comments
 (0)