Skip to content

Commit 11d7fa3

Browse files
authored
Merge pull request #148 from Wikidata/2025-05-refactor-scripts
Move listener to uwsgi daemon and add lag checker GH action
2 parents 9c87a36 + 3eefb47 commit 11d7fa3

File tree

13 files changed

+62
-109
lines changed

13 files changed

+62
-109
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Toolforge Check Lag
2+
on:
3+
schedule:
4+
- cron: "42 * * * *"
5+
workflow_dispatch:
6+
7+
jobs:
8+
check_lag:
9+
name: Check Lag
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
max-parallel: 4
14+
matrix:
15+
tool: ["editgroups"]
16+
17+
steps:
18+
- name: Configure SSH key
19+
uses: shimataro/ssh-key-action@v2
20+
with:
21+
key: ${{ secrets.SSH_PRIVATE_KEY }}
22+
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
23+
24+
- name: Run deployment commands
25+
uses: appleboy/[email protected]
26+
with:
27+
host: ${{ vars.SSH_HOST }}
28+
username: ${{ secrets.SSH_USER }}
29+
key: ${{ secrets.SSH_PRIVATE_KEY }}
30+
port: ${{ vars.SSH_PORT }}
31+
request_pty: true
32+
script: |
33+
set -xe
34+
become ${{ matrix.tool }} webservice python3.11 shell -- webservice-python-bootstrap
35+
become ${{ matrix.tool }} webservice python3.11 shell -- ./www/python/venv/bin/python ./www/python/src/manage.py check_lag
36+
if (( $? != 0 )); then
37+
become ${{ matrix.tool }} webservice python3.11 restart
38+
fi

.github/workflows/toolforge-deploy.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@ jobs:
3636
become ${{ matrix.tool }} webservice python3.11 shell -- '$HOME/www/python/venv/bin/python' '$HOME/www/python/src/manage.py' collectstatic --noinput
3737
become ${{ matrix.tool }} webservice python3.11 restart
3838
become ${{ matrix.tool }} webservice python3.11 status
39-
become ${{ matrix.tool }} ./www/python/src/restart_listener.sh
4039
become ${{ matrix.tool }} ./www/python/src/restart_celery.sh

deployment/celery.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Run the EventStream listener on kubernetes
1+
# Run Celery on kubernetes
22
apiVersion: apps/v1
33
kind: Deployment
44
metadata:

deployment/listener.yaml

Lines changed: 0 additions & 31 deletions
This file was deleted.

deployment/migrator.yaml

Lines changed: 0 additions & 31 deletions
This file was deleted.

docs/architecture.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ This process can be invoked directly as a script::
3737

3838
python listener.py
3939

40-
Or it can be run as a Kubernetes pod using the ``deployment/listener.yaml`` configuration provided.
40+
It can be run as an `attached daemon to uwsgi <https://uwsgi-docs.readthedocs.io/en/latest/AttachingDaemons.html>`_.
4141

4242
In the interest of running EditGroups on other Wikibase instances which do not have an associated EventStream
4343
endpoint, it would be great to add the possibility on ingesting edits by polling the recent changes too.

docs/install.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ Put the following content in ``~/www/python/uwsgi.ini``::
129129
[uwsgi]
130130
static-map = /static=/data/project/editgroups/www/python/src/static
131131

132-
and run ``./manage.py collectstatic`` in the ``~/www/python/src`` directory.
132+
master = true
133+
attach-daemon = /data/project/editgroups/www/python/venv/bin/python3 /data/project/editgroups/www/python/src/listener.py
134+
135+
and run ``./manage.py collectstatic`` in the ``~/www/python/src`` directory. The listener will be an attached dameon, restarting with webservice restart.
133136

134137

135138
Configure OAuth login:
@@ -156,9 +159,8 @@ Go to the webservice, login with OAuth to the application. This will create a ``
156159
user.is_staff = True
157160
user.save()
158161

159-
Launch the listener and Celery in Kubernetes. These deployment files may need to be adapted if you are not deploying the tool as the ``editgroups`` toolforge tool but another tool id:
162+
Launch Celery in Kubernetes. These deployment files may need to be adapted if you are not deploying the tool as the ``editgroups`` toolforge tool but another tool id:
160163

161-
- ``kubectl create -f deployment/listener.yaml``
162164
- ``kubectl create -f deployment/celery.yaml``
163165

164166
Backup the database regularly with:

listener.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

migrator.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

restart_listener.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)