Skip to content

Commit

Permalink
handle debug deployment configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
DerouineauNicolas committed Jun 18, 2024
1 parent ece5fad commit fdb3841
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 3 additions & 2 deletions backend/StreamServerApp/tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from celery import shared_task
from StreamServerApp.models import Video, Series, Movie, Subtitle
from StreamingServer.settings import STATIC_URL
from django.conf import settings
from StreamServerApp.media_management.cover_downloader import cover_downloader

Expand Down Expand Up @@ -34,10 +35,10 @@ def download_cover_async(id, name, is_tv_show=False):
video = Video.objects.get(id=id)
if is_tv_show:
serie = Series.objects.get(id=video.series_id)
serie.thumbnail = "/static/{}.jpeg".format(name)
serie.thumbnail = "{}{}.jpeg".format(STATIC_URL, name)
serie.save()
else:
video.thumbnail = "/static/{}.jpeg".format(name)
video.thumbnail = "{}{}.jpeg".format(STATIC_URL, name)
video.save()

return 0
2 changes: 2 additions & 0 deletions backend/StreamingServer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

STATIC_URL = '/static/'
STATIC_ROOT = '/usr/static/'
if os.getenv('DEPLOY_ENV', 'dev') == 'development':
STATIC_URL = 'http://localhost:1337/static/'

ALLOWED_HOSTS = ['web', 'localhost']

Expand Down
7 changes: 6 additions & 1 deletion backend/start_django_server.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
service transmission-daemon start
python3 /usr/src/app/manage.py collectstatic --no-input
python3 /usr/src/app/manage.py clearcache
gunicorn --workers=${NUM_GUNICORN_WORKER} StreamingServer.wsgi:application --bind 0.0.0.0:8000
if [[ "$DEPLOY_ENV" == "development" ]]
then
./wait-for-it.sh db:5432 -- python3 /usr/src/app/manage.py runserver 0.0.0.0:8000
else
gunicorn --workers=${NUM_GUNICORN_WORKER} StreamingServer.wsgi:application --bind 0.0.0.0:8000
fi
5 changes: 4 additions & 1 deletion docker-compose-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:
- .env
environment:
- DEBUG=1
- DEPLOY_ENV=development
volumes:
- ./backend/:/usr/src/app/
- ./log/:/debug/
Expand All @@ -40,7 +41,7 @@ services:
- /static/
- ipython:/root/.ipython
- torrent:/usr/torrent/:rw
command: bash -c "service transmission-daemon start && ./wait-for-it.sh db:5432 -- python3 /usr/src/app/manage.py runserver 0.0.0.0:8000"
command: bash -c "./start_django_server.sh"
depends_on:
- db
- redis
Expand Down Expand Up @@ -85,6 +86,8 @@ services:
- ./log/:/debug/
env_file:
- .env
environment:
- DEPLOY_ENV=development
depends_on:
- db
- redis
Expand Down

0 comments on commit fdb3841

Please sign in to comment.