diff --git a/.gitignore b/.gitignore index e84cdd1..c4b9363 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ public_html/out public_html/status *.log .pywikibot +.toolskube .python_history .cache ArkivBot.err diff --git a/arkivbot.crontab b/arkivbot.crontab deleted file mode 100644 index 8536602..0000000 --- a/arkivbot.crontab +++ /dev/null @@ -1,2 +0,0 @@ -MAILTO="" -0 1 * * * jsub -N ArkivBot /data/project/arkivbot/run.job diff --git a/bootstrap-venv.sh b/bootstrap-venv.sh new file mode 100755 index 0000000..1b79981 --- /dev/null +++ b/bootstrap-venv.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Usage: +# toolforge-jobs run bootstrap-venv --command "./bootstrap-venv.sh" --image python3.9 --wait +set -euo pipefail + +rm -rf ENV +python3 -m venv ENV + +. ENV/bin/activate + +# upgrade pip inside the venv and add support for the wheel package format +pip install -U pip wheel + +pip install requests mwparserfromhell wikitextparser + +cd $HOME/pywikibot +git pull +pip install -e .[mwparserfromhell,mwoauth,mysql] diff --git a/jobs.yaml b/jobs.yaml new file mode 100644 index 0000000..010dd23 --- /dev/null +++ b/jobs.yaml @@ -0,0 +1,8 @@ +--- +# Ref: https://wikitech.wikimedia.org/wiki/Help:Toolforge/Jobs_framework +- name: arkivbot + command: ./run.sh + image: python3.9 + schedule: "0 5 * * *" + emails: onfailure + diff --git a/run.job b/run.sh similarity index 73% rename from run.job rename to run.sh index 64acb9c..0efec2d 100755 --- a/run.job +++ b/run.sh @@ -2,24 +2,29 @@ # Note that main.log is stored in ~/.pywikibot/logs/ -cd /data/project/arkivbot - -# Update dependencies -./update_deps.sh - # Activate virtualenv . ENV/bin/activate +# Update pywikibot +echo "📦 Updating pywikibot" +cd pywikibot && git pull && cd .. + +echo "🏡 Working dir: $(pwd)" + # Set Pywikibot path # PYWIKI=/shared/pywikipedia/core -PYWIKI=/data/project/arkivbot/pywikibot -export PYTHONPATH=$PYWIKI/core:$PYWIKI/externals:$PYWIKI/scripts +PYWIKI=$(pwd)/pywikibot +export PYTHONPATH=$PYWIKI/scripts:$PYTHONPATH LOG=public_html/out STATUS=public_html/status rm $LOG touch $LOG +echo "------------------------------------------" +python $PYWIKI/pwb.py version +echo "------------------------------------------" + echo 'true' > $STATUS echo ----------------------------------------------------------- >> $LOG echo `date` : Bot started >> $LOG diff --git a/service.manifest b/service.manifest index 756cd2e..ea8c638 100644 --- a/service.manifest +++ b/service.manifest @@ -1,6 +1,6 @@ -# This file is used by toollabs infrastructure. +# This file is used by Toolforge infrastructure. # Please do not edit manually at this time. -backend: gridengine -distribution: debian -version: 2 -web: lighttpd +# Sun Apr 9 19:24:41 2023 +backend: kubernetes +version: 4 +web: php7.4 diff --git a/service.template b/service.template new file mode 100644 index 0000000..4c2e68d --- /dev/null +++ b/service.template @@ -0,0 +1,11 @@ +# Toolforge webservice template +# Provide default arguments for `webservice start` commands for this tool. +# +# Uncomment lines below and adjust as needed + +# Set backend cluster to run this webservice (--backend={gridengine,kubernetes}) +backend: kubernetes + +# Runtime type +# See "Supported webservice types" in `webservice --help` output for valid values. +type: php7.4 diff --git a/update_deps.sh b/update_deps.sh deleted file mode 100755 index 590285b..0000000 --- a/update_deps.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -cd pywikibot -git pull