This commit is contained in:
javad committed 2026-10-10 14:21:04 +03:30
1 parent 250cdbab7f
commit 5c6069c3ef
87 files changed
+29209 -3697

No files matched your search

+16 -3
View File
@@ -3,11 +3,19 @@
# ۱. متوقف کردن آنی کل فرآیند کانتینر در صورت بروز خطا در هر لایه
set -e
# اگر کامند سفارشی داده شده (worker/scheduler) می‌گریشن/استاتیک فقط در سرویس وب اجرا می‌شود
RUN_WEB_SETUP=1
if [ "$#" -gt 0 ] && [ "$1" != "gunicorn" ]; then
RUN_WEB_SETUP=0
fi
if [ "$RUN_WEB_SETUP" = "1" ]; then
echo "==> [1/4] Collecting Static Files..."
python manage.py collectstatic --noinput --clear
echo "==> [2/4] Running Database Migrations..."
python manage.py migrate --noinput
fi
echo "==> [3/4] Optimizing SQLite Storage (WAL & Synchronous)..."
# استفاده از بلاک EOF پایتون برای خوانایی، ایزولاسیون خطا و ثبت سیستماتیک لاگ‌ها
@@ -40,6 +48,11 @@ except Exception as e:
sys.exit(1)
EOF
echo "==> [4/4] Starting Gunicorn Web Server..."
# جایگزین کردن پروسس PID 1 با Gunicorn برای مدیریت اصولی سیگنال‌های توقف داکر (Graceful Shutdown)
exec gunicorn --bind 0.0.0.0:8000 khatibi.wsgi:application
echo "==> [4/4] Starting Application..."
# اگر کامند سفارشی داده شده باشد (مثل sms_worker/sms_scan) همان اجرا می‌شود؛
# در غیر این‌صورت وب‌سرور Gunicorn به‌عنوان PID 1 جایگزین می‌شود (Graceful Shutdown).
if [ "$#" -gt 0 ]; then
exec "$@"
else
exec gunicorn --bind 0.0.0.0:8000 khatibi.wsgi:application
fi