Skip to content

Commit

Permalink
feat: better logs for music; mount content; better rate limits
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfromyeg committed Jan 8, 2024
1 parent 1f9a404 commit e0af622
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bereal/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
storage_uri=f"redis://{REDIS_HOST}:{REDIS_PORT}/1",
storage_options={"socket_connect_timeout": 30},
strategy="fixed-window",
default_limits=["250 per day", "100 per hour", "5 per minute", "3 per second"],
default_limits=["500 per day", "200 per hour", "20 per minute", "5 per second"],
)

serializer = URLSafeTimedSerializer(SECRET_KEY)
Expand Down Expand Up @@ -176,18 +176,21 @@ def create_video() -> tuple[Response, int]:

song_folder = os.path.join(CONTENT_PATH, phone, year)
os.makedirs(song_folder, exist_ok=True)

song_path = os.path.join(song_folder, "song.wav")

if wav_file:
logger.debug("Downloading music file %s...", wav_file.filename)
logger.info("Downloading music file %s...", wav_file.filename)
try:
wav_file.save(song_path)
except Exception as error:
logger.warning("Could not save music file, received: %s", error)
song_path = DEFAULT_SONG_PATH
else:
logger.info("No music file provided; using default...")
song_path = DEFAULT_SONG_PATH

logger.debug("Queueing video task...")
logger.info("Queueing video task...")

# TODO(michaelfromyeg): replace token with bereal_token
task = make_video.delay(token, bereal_token, phone, year, song_path, mode)
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
dockerfile: docker/Dockerfile.server
volumes:
- ./exports:/app/exports
- ./content:/app/content
user: thekid
ports:
- "5000:5000"
Expand All @@ -21,6 +22,7 @@ services:
dockerfile: docker/Dockerfile.celery
volumes:
- ./exports:/app/exports
- ./content:/app/content
user: thekid
command: celery -A bereal.celery worker --loglevel=INFO --logfile=celery.log -E
environment:
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
dockerfile: docker/Dockerfile.server
volumes:
- /mnt/videos:/app/exports
- /mnt/content:/app/content
user: thekid
ports:
- "5000:5000"
Expand All @@ -22,6 +23,7 @@ services:
dockerfile: docker/Dockerfile.celery
volumes:
- /mnt/videos:/app/exports
- /mnt/content:/app/content
user: thekid
command: celery -A bereal.celery worker --loglevel=INFO --logfile=celery.log -E -c 1
environment:
Expand Down

0 comments on commit e0af622

Please sign in to comment.