Skip to content

Commit

Permalink
Migrate to Kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
danmichaelo committed Apr 9, 2023
1 parent 6ab4ce0 commit 623cef0
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,6 +2,7 @@ public_html/out
public_html/status
*.log
.pywikibot
.toolskube
.python_history
.cache
ArkivBot.err
Expand Down
2 changes: 0 additions & 2 deletions arkivbot.crontab

This file was deleted.

18 changes: 18 additions & 0 deletions 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]
8 changes: 8 additions & 0 deletions 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

19 changes: 12 additions & 7 deletions run.job → run.sh
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions 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
11 changes: 11 additions & 0 deletions 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
4 changes: 0 additions & 4 deletions update_deps.sh

This file was deleted.

0 comments on commit 623cef0

Please sign in to comment.