azils3 commited on
Commit
96d209a
·
verified ·
1 Parent(s): b20b7fe

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +11 -6
entrypoint.sh CHANGED
@@ -1,14 +1,19 @@
1
  #!/bin/bash
2
 
3
- # Create superuser if it doesn't exist
 
 
 
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]', 'your_password_here')" | python manage.py shell
7
  fi
8
 
9
- # Set the webhook for the Telegram bot
10
- echo "Setting webhook..."
11
- curl -s "https://api.telegram.org/bot$TELEGRAM_TOKEN/setWebhook?url=https://$HOST/super_secter_webhook/"
 
 
12
 
13
- # Start the Gunicorn server
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