-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
31 lines (24 loc) · 1.04 KB
/
start.sh
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
#!/bin/sh
echo "Starting application setup..."
# Apply database migrations (including background_task migrations)
echo "Applying database migrations..."
python manage.py makemigrations
python manage.py migrate --noinput
# Collect static files
python manage.py collectstatic --noinput
# Create superuser if DJANGO_SUPERUSER_USERNAME is set and the user does not already exist
if [ "$DJANGO_SUPERUSER_USERNAME" ]; then
echo "Checking if superuser exists..."
if ! python manage.py shell -c "from django.contrib.auth import get_user_model; User = get_user_model(); exit(User.objects.filter(username='$DJANGO_SUPERUSER_USERNAME').exists())"; then
echo "Creating superuser..."
python manage.py createsuperuser --noinput --username $DJANGO_SUPERUSER_USERNAME --email $DJANGO_SUPERUSER_EMAIL
fi
fi
# Apply the cron job
crontab /etc/cron.d/update
# Start the cron service
echo "Starting cron service..."
cron
# Start Gunicorn server for production
echo "Starting Gunicorn server..."
gunicorn LaundryTracker.wsgi:application --bind 0.0.0.0:8000 --workers 2