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
523if [ -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
931fi
1032
@@ -17,6 +39,7 @@ if docker ps -a --format '{{.Names}}' | grep -q "^embabel-hub$"; then
1739fi
1840
1941echo " Starting new embabel-hub container..."
42+ # pragma: allowlist secret
2043docker 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
3255if [ $? -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
3996else
4097 echo " ✗ Failed to start embabel-hub container"
4198 exit 1
0 commit comments