MDSplus.wsgi module - MdsWiki
Personal tools

From MdsWiki

Jump to: navigation, search

The MDSplus.wsgi module provides a variety of capabilities for accessing MDSplus data and events over the http protocol.

The wsgi module has several sub-functions that are referenced by adding the sub-function name to the url for the wsgi. For example the http mdsip data access plugin requires that your reference the mdsip sub-function by specifying a connection string such as http://webserver/MDSplusWsgi/mdsip.

Step 1 - Install the MDSplus python module

To configure an Apache web server to use the MDSplus.wsgi module you must first install the MDSplus python module on your web server system. The easiest ways to do that is using an MDSplus repository as described on the downloads page.

Once the MDSplus python module is installed on your system you can then begin to configure Apache to use the wsgi subpackage of the MDSplus module.

Step 2 - Configure the MDSplus wsgi subpackage

Create a directory on your web server which will contain configuration files needed to execute the wsgi plugin. For this example lets pick the directory "/var/www/mdsplusWsgi".

# mkdir /var/www/mdsplusWsgi

Create the wsgi startup file:

 # echo "from MDSplus.mdsplus_wsgi import application" > /var/www/mdsplusWsgi/mdsplus.wsgi

Or (alpha) copy from python MDSplus "./wsgi/conf/mdsplus.wsgi" into "/var/www/mdsplusWsgi/".

Create the wsgi configuration file to defined needed environment variables.

Create a configuration file called in the same directory to customize your wsgi for your site. The should be a python script that defines needed environment variables for MDSplus in the process context of the Apache server process. An example script might include:

 import subprocess,os
 # Get tree path environment variables configured in the MDSplus setup scripts 
 p=subprocess.Popen('. /usr/local/mdsplus/; printenv | grep _path=',stdout=subprocess.PIPE,shell=True)
 for env in defs:

Or (alpha) modify mdsplus.wsgi file instead.

The environment variables needed will depend on the wsgi features you will be using but in general should include most of the environment variables need if you were going to run MDSplus applications to access MDSplus data or to wait for or generate MDSplus events.

Step 3. - Configure Apache web server to use the MDSplus wsgi

You will need to add some configuration to the Apache web server. The way this is done varies with the version of the Apache software. The example shown here is for Apache www server version 2.2. Create an mdsplus.conf file in /etc/httpd/conf.d containing something like:

 LoadModule wsgi_module modules/
 WSGIScriptAlias /mdsplusWsgi /var/www/mdsplusWsgi/mdsplus.wsgi

where /mdsplus is url on your website to be used to reference this MDSplus wsgi module and the /var/www/mdsplusWsgi/mdsplus.wsgi is the location of the wsgi script you created in step 2.

Or (alpha) copy form python MDSplus "./wsgi/conf/mdsplus.conf" into "/etc/apache/mods-enabled/"

Soon we will include more documentation on the sub-functions currently provided in the MDSplus wsgi.