forked from airweave-ai/airweave
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·180 lines (148 loc) · 5.96 KB
/
start.sh
File metadata and controls
executable file
·180 lines (148 loc) · 5.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/bash
set -x # Enable debug mode to see what's happening
# Check if .env exists, if not create it from example
if [ ! -f .env ]; then
echo "Creating .env file from example..."
cp .env.example .env
echo ".env file created"
fi
# Generate new encryption key regardless of existing value
echo "Generating new encryption key..."
NEW_KEY=$(openssl rand -base64 32)
echo "Generated key: $NEW_KEY"
# Remove any existing ENCRYPTION_KEY line and create clean .env
grep -v "^ENCRYPTION_KEY=" .env > .env.tmp
mv .env.tmp .env
# Add the new encryption key at the end of the file
echo "ENCRYPTION_KEY=\"$NEW_KEY\"" >> .env
# Add SKIP_AZURE_STORAGE for faster local startup
if ! grep -q "^SKIP_AZURE_STORAGE=" .env; then
echo "SKIP_AZURE_STORAGE=true" >> .env
echo "Added SKIP_AZURE_STORAGE=true for faster startup"
fi
echo "Updated .env file. Current ENCRYPTION_KEY value:"
grep "^ENCRYPTION_KEY=" .env
# Ask for OpenAI API key
echo ""
echo "OpenAI API key is required for files and natural language search functionality."
read -p "Would you like to add your OPENAI_API_KEY now? You can also do this later by editing the .env file manually. (y/n): " ADD_OPENAI_KEY
if [ "$ADD_OPENAI_KEY" = "y" ] || [ "$ADD_OPENAI_KEY" = "Y" ]; then
read -p "Enter your OpenAI API key: " OPENAI_KEY
# Remove any existing OPENAI_API_KEY line
grep -v "^OPENAI_API_KEY=" .env > .env.tmp
mv .env.tmp .env
# Add the new OpenAI API key
echo "OPENAI_API_KEY=\"$OPENAI_KEY\"" >> .env
echo "OpenAI API key added to .env file."
else
echo "You can add your OPENAI_API_KEY later by editing the .env file manually."
echo "Add the following line to your .env file:"
echo "OPENAI_API_KEY=\"your-api-key-here\""
fi
# Ask for Mistral API key
echo ""
echo "Mistral API key is required for certain AI functionality."
read -p "Would you like to add your MISTRAL_API_KEY now? You can also do this later by editing the .env file manually. (y/n): " ADD_MISTRAL_KEY
if [ "$ADD_MISTRAL_KEY" = "y" ] || [ "$ADD_MISTRAL_KEY" = "Y" ]; then
read -p "Enter your Mistral API key: " MISTRAL_KEY
# Remove any existing MISTRAL_API_KEY line
grep -v "^MISTRAL_API_KEY=" .env > .env.tmp
mv .env.tmp .env
# Add the new Mistral API key
echo "MISTRAL_API_KEY=\"$MISTRAL_KEY\"" >> .env
echo "Mistral API key added to .env file."
else
echo "You can add your MISTRAL_API_KEY later by editing the .env file manually."
echo "Add the following line to your .env file:"
echo "MISTRAL_API_KEY=\"your-api-key-here\""
fi
# Check if "docker compose" is available (Docker Compose v2)
if docker compose version >/dev/null 2>&1; then
COMPOSE_CMD="docker compose"
# Else, fall back to "docker-compose" (Docker Compose v1)
elif docker-compose --version >/dev/null 2>&1; then
COMPOSE_CMD="docker-compose"
elif podman-compose --version > /dev/null 2>&1; then
COMPOSE_CMD="podman-compose"
else
echo "Neither 'docker compose', 'docker-compose', nor 'podman-compose' found. Please install Docker Compose."
exit 1
fi
# Add this block: Check if Docker daemon is running
if docker info > /dev/null 2>&1; then
CONTAINER_CMD="docker"
elif podman info > /dev/null 2>&1; then
CONTAINER_CMD="podman"
else
echo "Error: Docker daemon is not running. Please start Docker and try again."
exit 1
fi
echo "Using commands: ${CONTAINER_CMD} and ${COMPOSE_CMD}"
# Check for existing airweave containers
EXISTING_CONTAINERS=$(${CONTAINER_CMD} ps -a --filter "name=airweave" --format "{{.Names}}" | tr '\n' ' ')
if [ -n "$EXISTING_CONTAINERS" ]; then
echo "Found existing airweave containers: $EXISTING_CONTAINERS"
read -p "Would you like to remove them before starting? (y/n): " REMOVE_CONTAINERS
if [ "$REMOVE_CONTAINERS" = "y" ] || [ "$REMOVE_CONTAINERS" = "Y" ]; then
echo "Removing existing containers..."
${CONTAINER_CMD} rm -f $EXISTING_CONTAINERS
# Also remove the database volume
echo "Removing database volume..."
${CONTAINER_CMD} volume rm airweave_postgres_data
echo "Containers and volumes removed."
else
echo "Warning: Starting with existing containers may cause conflicts."
fi
fi
# Now run the appropriate Docker Compose command with the new path
$COMPOSE_CMD -f docker/docker-compose.yml up -d
# Wait a moment for services to initialize
echo ""
echo "Waiting for services to initialize..."
sleep 10
# Check if backend is healthy (with retries)
echo "Checking backend health..."
MAX_RETRIES=30
RETRY_COUNT=0
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
if ${CONTAINER_CMD} exec airweave-backend curl -f http://localhost:8001/health >/dev/null 2>&1; then
echo "✅ Backend is healthy!"
break
else
echo "⏳ Backend is still starting... (attempt $((RETRY_COUNT + 1))/$MAX_RETRIES)"
RETRY_COUNT=$((RETRY_COUNT + 1))
sleep 5
fi
done
# Check if frontend needs to be started manually
FRONTEND_STATUS=$(${CONTAINER_CMD} inspect airweave-frontend --format='{{.State.Status}}' 2>/dev/null)
if [ "$FRONTEND_STATUS" = "created" ] || [ "$FRONTEND_STATUS" = "exited" ]; then
echo "Starting frontend container..."
${CONTAINER_CMD} start airweave-frontend
sleep 5
fi
# Final status check
echo ""
echo "🚀 Airweave Status:"
echo "=================="
# Check each service
if ${CONTAINER_CMD} exec airweave-backend curl -f http://localhost:8001/health >/dev/null 2>&1; then
echo "✅ Backend API: http://localhost:8001"
else
echo "❌ Backend API: Not responding (check logs with: docker logs airweave-backend)"
fi
if curl -f http://localhost:8080 >/dev/null 2>&1; then
echo "✅ Frontend UI: http://localhost:8080"
else
echo "❌ Frontend UI: Not responding (check logs with: docker logs airweave-frontend)"
fi
echo ""
echo "Other services:"
echo "📊 Temporal UI: http://localhost:8088"
echo "🗄️ PostgreSQL: localhost:5432"
echo "🔍 Qdrant: http://localhost:6333"
echo ""
echo "To view logs: docker logs <container-name>"
echo "To stop all services: docker compose -f docker/docker-compose.yml down"
echo ""
echo "Services started!"