Running wiki-to-print on the server: Difference between revisions

From creative crowd wiki
Jump to navigation Jump to search
(Created page with " ===To run wiki-to-print in the background=== $ sudo service wiki2print status $ sudo service wiki2print start $ sudo service wiki2print stop $ sudo service wiki2print restart ===For debugging=== You can find the files of wiki-to-print here: $ cd /var/www/wiki2print/web-interface/ $ ls ├── Makefile ├── __pycache__ ├── api.py ├── plugins ├── readme.md ├── requirements.txt ├── static ├── templates ├─...")
 
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__TOC__


===To run wiki-to-print in the background===
'''Official disclaimer''': Many things can happen, 502 errors fly around your ears, wiki-to-print is not a product :) as long as it keeps running we're happy.
 
BUT...
 
If you're stuck, this may be of use.
 
==Wiki-to-print as a service==
 
Wiki-to-print is a Flask application that runs in the background as a service, using a systemd service file.


  $ sudo service wiki2print status
  $ sudo service wiki2print status
  $ sudo service wiki2print start
  $ sudo service wiki2print start
  $ sudo service wiki2print stop
  $ sudo service wiki2print stop
  $ sudo service wiki2print restart
  $ sudo service wiki2print restart


===For debugging===
* The service is configured at: <code>/etc/systemd/system/wiki-to-print.service</code>
* Here is an example of that file: https://git.vvvvvvaria.org/varia/wiki-to-print/src/branch/master/wiki-to-print.service.example
 
==Debugging==


You can find the files of wiki-to-print here:
===For debugging (on the server)===


$ cd /var/www/wiki2print/web-interface/
Stop the wiki2print service:


  $ ls
  $ sudo service wiki2print stop


├── Makefile
Then run wiki-to-print manually from the folder where it is installed. First go to this folder:
├── __pycache__
├── api.py
├── plugins
├── readme.md
├── requirements.txt
├── static
├── templates
├── update.py
├── venv
└── web-interface.py


* <code>web-interface.py</code>: the flask application
$ cd /var/www/wiki-to-print/wiki-to-print/
* <code>api.py</code>: script with all the functions that are used by the flask application


You can run the flask application directly (instead of running it as a systemd service):
And then run the application:


  $ make server
  $ make server


If you add prints statements in the python files you can see the result in the terminal.
And if needed, you can add print statements in the python files to dive deeper into the code.
 
===For debugging (through a local installation)===
 
$ git clone ssh://gitea@vvvvvvaria.org:12345/varia/wiki-to-print.git
 
$ cd wiki-to-print/wiki-to-print/web-interface/
 
$ make setup
 
$ make local
 
==jobrunner==
MediaWiki comes with a maintenance script called <code>RunJobs.php</code> that writes changes to the database. The job queue is a built-in feature of MediaWiki that is made to increase the performance on large wikis.
 
On CC we use a script called <code>jobrunner.sh</code> in <code>/var/www/html/wiki/</code> that is based on: https://www.mediawiki.org/wiki/Manual:Job_queue#Continuous_service
 
It runs the MediaWiki maintenance script <code>RunJobs.php</code> '''every 10 seconds'''.
 
It is installed on CC and runs in the background as a systemd service, called "jobrunner", which can be used with:
 
$ sudo service jobrunner status
$ sudo service jobrunner start
$ sudo service jobrunner stop
$ sudo service jobrunner reload
 
* The service is configured at: <code>/etc/systemd/system/jobrunner.service</code>
* This is an example of the service file:
 
[Unit]
Description=MediaWiki Job runner
[Service]
ExecStart=/var/www/html/wiki/jobrunner.sh
Nice=10
ProtectSystem=full
User=www-data
OOMScoreAdjust=200
StandardOutput=journal
[Install]
WantedBy=multi-user.target
 
[[Category:Sysadmin]]
[[Category:Wiki-to-print]]

Latest revision as of 15:58, 22 August 2023

Official disclaimer: Many things can happen, 502 errors fly around your ears, wiki-to-print is not a product :) as long as it keeps running we're happy.

BUT...

If you're stuck, this may be of use.

Wiki-to-print as a service

Wiki-to-print is a Flask application that runs in the background as a service, using a systemd service file.

$ sudo service wiki2print status
$ sudo service wiki2print start
$ sudo service wiki2print stop
$ sudo service wiki2print restart

Debugging

For debugging (on the server)

Stop the wiki2print service:

$ sudo service wiki2print stop

Then run wiki-to-print manually from the folder where it is installed. First go to this folder:

$ cd /var/www/wiki-to-print/wiki-to-print/

And then run the application:

$ make server

And if needed, you can add print statements in the python files to dive deeper into the code.

For debugging (through a local installation)

$ git clone ssh://gitea@vvvvvvaria.org:12345/varia/wiki-to-print.git
$ cd wiki-to-print/wiki-to-print/web-interface/
$ make setup
$ make local

jobrunner

MediaWiki comes with a maintenance script called RunJobs.php that writes changes to the database. The job queue is a built-in feature of MediaWiki that is made to increase the performance on large wikis.

On CC we use a script called jobrunner.sh in /var/www/html/wiki/ that is based on: https://www.mediawiki.org/wiki/Manual:Job_queue#Continuous_service

It runs the MediaWiki maintenance script RunJobs.php every 10 seconds.

It is installed on CC and runs in the background as a systemd service, called "jobrunner", which can be used with:

$ sudo service jobrunner status
$ sudo service jobrunner start
$ sudo service jobrunner stop
$ sudo service jobrunner reload
  • The service is configured at: /etc/systemd/system/jobrunner.service
  • This is an example of the service file:
[Unit]
Description=MediaWiki Job runner

[Service]
ExecStart=/var/www/html/wiki/jobrunner.sh
Nice=10
ProtectSystem=full
User=www-data
OOMScoreAdjust=200
StandardOutput=journal

[Install]
WantedBy=multi-user.target