azils3 commited on
Commit
4caa71b
·
verified ·
1 Parent(s): 59edad6

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +6 -5
entrypoint.sh CHANGED
@@ -1,19 +1,20 @@
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
 
1
  #!/bin/bash
2
 
3
+ # Run migrations and static collection at runtime
4
  python manage.py migrate
5
+ python manage.py collectstatic --noinput
6
 
7
+ # Create admin user if not exists
8
  if ! python manage.py shell -c "from django.contrib.auth import get_user_model; print(get_user_model().objects.filter(username='admin').exists())"; then
9
  echo "Creating superuser..."
10
  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
11
  fi
12
 
13
+ # Start server and set webhook
14
  {
15
+ sleep 3 # Wait for server to initialize
16
+ echo "Setting webhook..."
17
  curl -s "https://api.telegram.org/bot${TELEGRAM_TOKEN}/setWebhook?url=https://${HOST}/super_secter_webhook/"
18
  } &
19
 
 
20
  exec gunicorn --bind 0.0.0.0:$PORT dtb.wsgi:application