Personal tools

Extension talk:Daemoniser.php

From OrganicDesign Wiki

Jump to: navigation, search
This will probably be included as an option in the MediaWikiLite extension


Run MediaWiki instance from shell as a daemon which exhibits a socket listener so no need for webserver. Designed to work in conjunction with Extension:SQLite.php for running MediaWiki on iPod/iPhone and to help develop the PeerPedia idea.

1 Program Structure

The idea would be to add a MediaWiki extension which allows the script to be run from the commandline (either by being included from LocalSettings.php or being called directly). This master script daemonises itself, then runs a set number of persistent child processes which will all be mediawiki's which also work as daemons but are under the control of the parent daemon.

The parent is also the master web socket listener and accepts incoming requests and hands the handle to the least busy child process (either one which is idle, or otherwise the one which has been processing its request for longest. The parent process is also responsible for killing zombie's. The child processes must process requests from the parent and then send the response to the client handle (given to it by the parent).

1.1 Reinitialising the MediaWiki Environment

After it sends the response, it must reinitialise the MediaWiki environment and then send a message to the parent process declaring itself as ready for more work.

Reinitialising the MediaWiki environment can be done by taking a snapshot of the entire global namespace's values when the process first starts, this could be done by the parent before it forks so that all children inherit the snapshot automatically. After each client response is sent, the environment can then reinitialise its global environment from the snapshot, and then report itself idle.

After this reinitialisation is working, a list of exceptions can be created which removes selected items from the snapshot so that they are not reinitialised. Some things will not, or should not be reinitialised such as the load balancer. Other things may not need to be such as the Parser and could increase performance significantly by not requiring reinitialisation.

2 See also

The GNU Project Debian Linux Ubuntu Linux Wikipedia online encycopedia MediaWiki