|
#!/bin/sh |
|
set -e |
|
|
|
echo "[entrypoint] v2025-08-16-permissions-fix" |
|
|
|
|
|
echo "[entrypoint] ensuring data directories exist with proper permissions..." |
|
|
|
mkdir -p /data/advisorai-data \ |
|
/data/merged \ |
|
/data/alpaca \ |
|
/data/crypto-bubbles \ |
|
/data/finnhub \ |
|
/data/finviz \ |
|
/data/marketaux \ |
|
/data/logs \ |
|
/tmp/nginx/body \ |
|
/tmp/nginx/proxy \ |
|
/tmp/nginx/fastcgi |
|
|
|
|
|
|
|
chown -R $(id -u):$(id -g) /data /tmp/nginx 2>/dev/null || true |
|
chmod -R 777 /data /tmp/nginx 2>/dev/null || true |
|
|
|
echo "[entrypoint] restoring data from Filebase…" |
|
|
|
python /app/deployment/fetch_filebase.py & |
|
FETCH_PID=$! |
|
|
|
|
|
sleep 10 |
|
|
|
|
|
if kill -0 $FETCH_PID 2>/dev/null; then |
|
echo "[entrypoint] Data fetch still running in background (PID: $FETCH_PID)" |
|
else |
|
echo "[entrypoint] Data fetch completed" |
|
fi |
|
|
|
echo "[entrypoint] launching services…" |
|
|
|
|
|
ROLE_ENV=${ROLE:-web} |
|
echo "[entrypoint] detected ROLE=$ROLE_ENV" |
|
|
|
if [ "$ROLE_ENV" = "worker" ]; then |
|
echo "[entrypoint] starting worker: scheduler only" |
|
exec python /app/deployment/scheduler.py |
|
else |
|
|
|
if [ "${HF_MODE:-0}" = "1" ]; then |
|
export PORT=${PORT:-7860} |
|
echo "[entrypoint] HF_MODE=1 -> launching uvicorn directly on PORT=$PORT" |
|
exec uvicorn src.api.main:app --host 0.0.0.0 --port ${PORT} --workers 1 --timeout-keep-alive 30 |
|
else |
|
|
|
if [ -n "$PORT" ]; then |
|
echo "[entrypoint] configuring nginx to listen on PORT=$PORT" |
|
sed -i "s/listen 80;/listen ${PORT};/" /etc/nginx/conf.d/app.conf || true |
|
fi |
|
exec supervisord -c /etc/supervisord.conf |
|
fi |
|
fi |