mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
chore: improved configuration management and logging
This commit is contained in:
parent
6b07fcb131
commit
b8478f2ec0
6 changed files with 102 additions and 53 deletions
|
|
@ -8,6 +8,40 @@ echo "==========================================="
|
|||
# Create log directory
|
||||
mkdir -p /var/log/supervisor
|
||||
|
||||
# ================================================
|
||||
# Ensure data directory exists
|
||||
# ================================================
|
||||
mkdir -p /data
|
||||
|
||||
# ================================================
|
||||
# Generate SECRET_KEY if not provided
|
||||
# ================================================
|
||||
if [ -z "$SECRET_KEY" ]; then
|
||||
# Generate a random secret key and persist it
|
||||
if [ -f /data/.secret_key ]; then
|
||||
export SECRET_KEY=$(cat /data/.secret_key)
|
||||
echo "✅ Using existing SECRET_KEY from persistent storage"
|
||||
else
|
||||
export SECRET_KEY=$(python3 -c "import secrets; print(secrets.token_urlsafe(32))")
|
||||
echo "$SECRET_KEY" > /data/.secret_key
|
||||
chmod 600 /data/.secret_key
|
||||
echo "✅ Generated new SECRET_KEY (saved for persistence)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ================================================
|
||||
# Set default TTS/STT services if not provided
|
||||
# ================================================
|
||||
if [ -z "$TTS_SERVICE" ]; then
|
||||
export TTS_SERVICE="local/kokoro"
|
||||
echo "✅ Using default TTS_SERVICE: local/kokoro"
|
||||
fi
|
||||
|
||||
if [ -z "$STT_SERVICE" ]; then
|
||||
export STT_SERVICE="local/base"
|
||||
echo "✅ Using default STT_SERVICE: local/base"
|
||||
fi
|
||||
|
||||
# ================================================
|
||||
# Initialize PostgreSQL if needed
|
||||
# ================================================
|
||||
|
|
@ -18,7 +52,8 @@ if [ ! -f /data/postgres/PG_VERSION ]; then
|
|||
chown -R postgres:postgres /data/postgres
|
||||
chmod 700 /data/postgres
|
||||
|
||||
su - postgres -c "/usr/lib/postgresql/14/bin/initdb -D /data/postgres"
|
||||
# Initialize with UTF8 encoding (required for proper text handling)
|
||||
su - postgres -c "/usr/lib/postgresql/14/bin/initdb -D /data/postgres --encoding=UTF8 --locale=C.UTF-8"
|
||||
|
||||
# Configure PostgreSQL for connections
|
||||
echo "host all all 0.0.0.0/0 md5" >> /data/postgres/pg_hba.conf
|
||||
|
|
@ -104,6 +139,8 @@ echo " Backend API: http://localhost:8000"
|
|||
echo " API Docs: http://localhost:8000/docs"
|
||||
echo " Auth Type: ${AUTH_TYPE:-LOCAL}"
|
||||
echo " ETL Service: ${ETL_SERVICE:-DOCLING}"
|
||||
echo " TTS Service: ${TTS_SERVICE}"
|
||||
echo " STT Service: ${STT_SERVICE}"
|
||||
echo "==========================================="
|
||||
echo ""
|
||||
|
||||
|
|
@ -111,5 +148,5 @@ echo ""
|
|||
# Start Supervisor (manages all services)
|
||||
# ================================================
|
||||
echo "🚀 Starting all services..."
|
||||
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/surfsense.conf
|
||||
exec /usr/local/bin/supervisord -c /etc/supervisor/conf.d/surfsense.conf
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
[supervisord]
|
||||
nodaemon=true
|
||||
logfile=/var/log/supervisor/supervisord.log
|
||||
logfile=/dev/stdout
|
||||
logfile_maxbytes=0
|
||||
pidfile=/var/run/supervisord.pid
|
||||
childlogdir=/var/log/supervisor
|
||||
loglevel=info
|
||||
user=root
|
||||
|
||||
[unix_http_server]
|
||||
|
|
@ -22,8 +23,10 @@ user=postgres
|
|||
autostart=true
|
||||
autorestart=true
|
||||
priority=10
|
||||
stdout_logfile=/var/log/supervisor/postgresql.log
|
||||
stderr_logfile=/var/log/supervisor/postgresql-error.log
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
environment=PGDATA="/data/postgres"
|
||||
|
||||
# Redis
|
||||
|
|
@ -32,8 +35,10 @@ command=/usr/bin/redis-server --dir /data/redis --appendonly yes
|
|||
autostart=true
|
||||
autorestart=true
|
||||
priority=20
|
||||
stdout_logfile=/var/log/supervisor/redis.log
|
||||
stderr_logfile=/var/log/supervisor/redis-error.log
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
|
||||
# Backend API
|
||||
[program:backend]
|
||||
|
|
@ -44,8 +49,10 @@ autorestart=true
|
|||
priority=30
|
||||
startsecs=10
|
||||
startretries=3
|
||||
stdout_logfile=/var/log/supervisor/backend.log
|
||||
stderr_logfile=/var/log/supervisor/backend-error.log
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
environment=PYTHONPATH="/app/backend",UVICORN_LOOP="asyncio",UNSTRUCTURED_HAS_PATCHED_LOOP="1"
|
||||
|
||||
# Celery Worker
|
||||
|
|
@ -57,8 +64,10 @@ autorestart=true
|
|||
priority=40
|
||||
startsecs=15
|
||||
startretries=3
|
||||
stdout_logfile=/var/log/supervisor/celery-worker.log
|
||||
stderr_logfile=/var/log/supervisor/celery-worker-error.log
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
environment=PYTHONPATH="/app/backend"
|
||||
|
||||
# Celery Beat (scheduler)
|
||||
|
|
@ -70,8 +79,10 @@ autorestart=true
|
|||
priority=50
|
||||
startsecs=20
|
||||
startretries=3
|
||||
stdout_logfile=/var/log/supervisor/celery-beat.log
|
||||
stderr_logfile=/var/log/supervisor/celery-beat-error.log
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
environment=PYTHONPATH="/app/backend"
|
||||
|
||||
# Frontend
|
||||
|
|
@ -83,8 +94,10 @@ autorestart=true
|
|||
priority=60
|
||||
startsecs=5
|
||||
startretries=3
|
||||
stdout_logfile=/var/log/supervisor/frontend.log
|
||||
stderr_logfile=/var/log/supervisor/frontend-error.log
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
environment=NODE_ENV="production",PORT="3000",HOSTNAME="0.0.0.0"
|
||||
|
||||
# Process Groups
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue