Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions jobs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
- command: python utils/cleanuptasks.py
filelog: 'yes'
filelog-stderr: /data/project/video2commons/cleanup.err
filelog-stdout: /data/project/video2commons/cleanup.out
image: python3.9
name: cleanup
schedule: 23 7 * * *

- command: bash cleanuploads.sh
filelog: 'yes'
filelog-stderr: /data/project/video2commons/cleanuploads.err
filelog-stdout: /data/project/video2commons/cleanuploads.out
image: bullseye
name: cleanuploads
schedule: 28 7 * * *

- command: bash utils/update-yt-dlp-toolforge.sh
filelog: 'yes'
filelog-stderr: /data/project/video2commons/update-yt-dlp.err
filelog-stdout: /data/project/video2commons/update-yt-dlp.out
image: python3.11
name: update-yt-dlp
schedule: 33 7 * * *
7 changes: 7 additions & 0 deletions puppet/backend.pp
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,10 @@
minute => '0',
require => Service['v2ccelery'],
}
cron::job { 'v2cytdlp':
command => '/bin/bash /srv/v2c/utils/update-yt-dlp-encoder.sh',
user => 'root',
minute => '32',
hour => '6',
require => Service['v2ccelery'],
}
35 changes: 35 additions & 0 deletions utils/update-yt-dlp-encoder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Upgrades yt-dlp in the encoder venv.
#
# Celery is only restarted when the installed version actually changed, and the
# service is running (e.g. not restarting or manually stopped).

set -e

VENV_PIP=/srv/v2c/venv/bin/pip3

installed_version() {
"$VENV_PIP" show yt-dlp | sed -n 's/^Version: //p'
}

before=$(installed_version)

"$VENV_PIP" install -U 'yt-dlp[default]'

after=$(installed_version)

if [ "$before" = "$after" ]; then
echo "yt-dlp is already at $after, nothing to do"
exit 0
fi

sub_state=$(systemctl show v2ccelery.service --property=SubState --value)

if [ "$sub_state" != "running" ]; then
echo "yt-dlp went from '$before' to '$after', but skipping restart as celery is '$sub_state'"
exit 0
fi

echo "yt-dlp went from '$before' to '$after', restarting celery"
systemctl --no-block restart v2ccelery.service
30 changes: 30 additions & 0 deletions utils/update-yt-dlp-toolforge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Upgrades yt-dlp in the frontend venv.
#
# The webservice is only reloaded when the installed version actually changed.
# The reload happens through uwsgi's 'touch-reload' option, since the toolforge
# CLI is not usable from the job image.

set -e

VENV_PIP="$HOME/www/python/venv/bin/pip3"
RELOAD_TRIGGER="$HOME/www/python/reload"

installed_version() {
"$VENV_PIP" show yt-dlp | sed -n 's/^Version: //p'
}

before=$(installed_version)

"$VENV_PIP" install -U 'yt-dlp[default]'

after=$(installed_version)

if [ "$before" = "$after" ]; then
echo "yt-dlp is already at $after, nothing to do"
exit 0
fi

echo "yt-dlp went from '$before' to '$after', reloading the webservice"
touch "$RELOAD_TRIGGER"
Empty file added www/python/reload
Empty file.
5 changes: 5 additions & 0 deletions www/python/uwsgi.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[uwsgi]
# 10 MiB log rotation
log-maxsize = 10485760
# Touched by utils/update-yt-dlp-toolforge.sh after a yt-dlp upgrade
touch-reload = %dreload
Loading