Update entrypoint.sh
Browse files- entrypoint.sh +11 -6
entrypoint.sh
CHANGED
@@ -1,14 +1,19 @@
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
-
#
|
|
|
|
|
|
|
4 |
if ! python manage.py shell -c "from django.contrib.auth import get_user_model; print(get_user_model().objects.filter(username='admin').exists())"; then
|
5 |
echo "Creating superuser..."
|
6 |
-
echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', '[email protected]', '
|
7 |
fi
|
8 |
|
9 |
-
# Set
|
10 |
-
|
11 |
-
|
|
|
|
|
12 |
|
13 |
-
# Start
|
14 |
exec gunicorn --bind 0.0.0.0:$PORT dtb.wsgi:application
|
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
+
# Run migrations at runtime (after env vars are available)
|
4 |
+
python manage.py migrate
|
5 |
+
|
6 |
+
# Create superuser if not exists
|
7 |
if ! python manage.py shell -c "from django.contrib.auth import get_user_model; print(get_user_model().objects.filter(username='admin').exists())"; then
|
8 |
echo "Creating superuser..."
|
9 |
+
echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', '[email protected]', '${DJANGO_ADMIN_PASSWORD}')" | python manage.py shell
|
10 |
fi
|
11 |
|
12 |
+
# Set webhook after server starts
|
13 |
+
{
|
14 |
+
sleep 5 # Wait for server to start
|
15 |
+
curl -s "https://api.telegram.org/bot${TELEGRAM_TOKEN}/setWebhook?url=https://${HOST}/super_secter_webhook/"
|
16 |
+
} &
|
17 |
|
18 |
+
# Start server
|
19 |
exec gunicorn --bind 0.0.0.0:$PORT dtb.wsgi:application
|