|
|
#!/bin/bash |
|
|
set -e |
|
|
|
|
|
|
|
|
export HOME=/home/user |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export chroma_host="127.0.0.1" |
|
|
export chroma_port="8080" |
|
|
export chroma_collection="prepai_collection" |
|
|
export CHROMA_PATH="/tmp/chroma_store" |
|
|
|
|
|
|
|
|
echo "π¨ Setting up ChromaDB..." |
|
|
mkdir -p "$CHROMA_PATH" |
|
|
|
|
|
chroma run --host 0.0.0.0 --port 8080 --path "$CHROMA_PATH" & |
|
|
|
|
|
|
|
|
echo "π Starting Nginx..." |
|
|
mkdir -p /tmp/nginx/body /tmp/nginx/proxy /tmp/nginx/fastcgi /tmp/nginx/uwsgi /tmp/nginx/scgi |
|
|
|
|
|
cat <<EOF > /tmp/nginx.conf |
|
|
worker_processes 1; |
|
|
daemon off; |
|
|
pid /tmp/nginx.pid; |
|
|
error_log /tmp/error.log; |
|
|
events { worker_connections 1024; } |
|
|
http { |
|
|
include /etc/nginx/mime.types; |
|
|
default_type application/octet-stream; |
|
|
access_log /tmp/access.log; |
|
|
client_body_temp_path /tmp/nginx/body; |
|
|
proxy_temp_path /tmp/nginx/proxy; |
|
|
fastcgi_temp_path /tmp/nginx/fastcgi; |
|
|
uwsgi_temp_path /tmp/nginx/uwsgi; |
|
|
scgi_temp_path /tmp/nginx/scgi; |
|
|
|
|
|
server { |
|
|
listen 7860; |
|
|
server_name localhost; |
|
|
location / { |
|
|
root /usr/share/nginx/html; |
|
|
index index.html index.htm; |
|
|
try_files \$uri \$uri/ /index.html; |
|
|
} |
|
|
location /api/v1/ { |
|
|
proxy_pass http://127.0.0.1:8000/api/v1/; |
|
|
proxy_set_header Host \$host; |
|
|
proxy_set_header X-Real-IP \$remote_addr; |
|
|
} |
|
|
} |
|
|
} |
|
|
EOF |
|
|
|
|
|
nginx -c /tmp/nginx.conf & |
|
|
|
|
|
|
|
|
|
|
|
echo "β³ Waiting for ChromaDB to be responsive on port 8080..." |
|
|
|
|
|
timeout 30s bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/127.0.0.1/8080; do sleep 1; done' |
|
|
|
|
|
if [ $? -ne 0 ]; then |
|
|
echo "β Error: ChromaDB failed to start within 30 seconds." |
|
|
exit 1 |
|
|
fi |
|
|
echo "β
ChromaDB is ready." |
|
|
|
|
|
|
|
|
echo "π Starting Backend..." |
|
|
cd Backend |
|
|
|
|
|
python run.py |