MongoChemWeb: Difference between revisions
No edit summary |
No edit summary |
||
Line 83: | Line 83: | ||
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. | Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. | ||
<source lang="XML"> | |||
<VirtualHost *:80> | <VirtualHost *:80> | ||
# The hostname need to be updated | # The hostname need to be updated | ||
Line 89: | Line 90: | ||
ErrorLog "logs/mongochemweb-error_log" | ErrorLog "logs/mongochemweb-error_log" | ||
CustomLog "logs/mongochemweb-access_log" common | CustomLog "logs/mongochemweb-access_log" common | ||
# This rule is used to pass session requests to the launcher | # This rule is used to pass session requests to the launcher | ||
ProxyPass /session http://localhost:9000/session | ProxyPass /session http://localhost:9000/session | ||
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated | # Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated | ||
# if tangelo is being run as a different user. | # if tangelo is being run as a different user. | ||
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/ | ProxyPass / http://localhost:8080/~tangelo/mongochemweb/ | ||
# Turn on the rewrite engine | # Turn on the rewrite engine | ||
RewriteEngine On | RewriteEngine On | ||
# This is the path the mapping file the launcher will create | # This is the path the mapping file the launcher will create | ||
RewriteMap session-to-port txt:/tmp/mapping.txt | RewriteMap session-to-port txt:/tmp/mapping.txt | ||
# This is the rewrite condition. Look for anything with a sessionId= in the query part of the URL and capture the value to use below. | # This is the rewrite condition. Look for anything with a sessionId= in the query part of the URL and capture the value to use below. | ||
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC] | RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC] | ||
# This does the rewrite using the mapping file and the sessionId | # This does the rewrite using the mapping file and the sessionId | ||
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P] | RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P] | ||
</VirtualHost> | </VirtualHost> | ||
</source> | |||
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it: | Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it: |
Revision as of 12:40, 21 February 2014
The following steps are required for the deployment of MongoChemWeb:
Building VTK with web support
$ git clone git://vtk.org/VTK.git VTK $ mkdir VTK-build $ cd VTK-build $ cmake -DVTK_Group_Web:BOOL=ON ../VTK $ make
Building with Mesa
For offscreen rendering you will need to build OSMesa. The Mesa 9.2.2 OSMesa Gallium llvmpipe state-tracker is the preferred Mesa back-end renderer for VTK. The following shows how to configure it with system installed LLVM. Our strategy is to configure Mesa with the minimal number of options needed for OSMesa. This greatly simplifies the build, as many of the other drivers/renderers depend on X11 or other libraries. The following set of options are from the Mesa v9.2.2 release. Older or newer releases may require slightly different options. Consult
./configure --help for the details. autoreconf -fi ./configure \ CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \ CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \ --disable-xvmc \ --disable-glx \ --disable-dri \ --with-dri-drivers="" \ --with-gallium-drivers="swrast" \ --enable-texture-float \ --disable-shared-glapi \ --disable-egl \ --with-egl-platforms="" \ --enable-gallium-osmesa \ --enable-gallium-llvm=yes \ --with-llvm-shared-libs \ --prefix=/opt/mesa/9.2.2/llvmpipe
make make install
Some explanation of these options: DEFAULT_SOFTWARE_DEPTH_BITS=31 This sets the internal depth buffer precision for the OSMesa rendering context. In our experience, this is necessary to avoid z-buffer fighting during parallel rendering. Note that we have used this in-place of --with-osmesa-bits=32, which sets both depth buffer and color buffers to 32 bit precision. Because of a bug in Mesa, this introduces over 80 ctest regression failures in VTK related to line drawing. --enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms. To use Mesa with VTK you will need to set the following options before building VTK:
VTK_USE_X OFF VTK_OPENGL_HAS_OSMESA ON
Building OpenChemistry
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.
Apache compile, install and configuration
Apache 2.4.7 has support for rewriting websocket URL so can be used to proxy VTK web connections, this is the easiest way to configure Apache. However, if you are using a older version of Apache you can use the cusom proxy code based on mod_python.
Using Apache 2.4.7 Build/Installation
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz $ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz $ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz Now unpack everything in the right places. $ mkdir apache-2.4.7-src $ cd apache-2.4.7-src $ tar zxvf ../httpd.tgz $ cd httpd-2.4.7/srclib $ tar zxvf ../../../apr.tgz $ mv apr-1.5.0 apr $ tar zxvf ../../../apr-util.tgz $ mv apr-util-1.5.3 apr-util
Now configure the Apache build. $ cd apache-2.4.7-src/httpd-2.4.7 $ ./configure --with-included-apr --enable-proxy $ make $ sudo make install
Configuration
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/.
<VirtualHost *:80>
# The hostname need to be updated
ServerName hostname
ServerAdmin webmaster@example-host.example.com
ErrorLog "logs/mongochemweb-error_log"
CustomLog "logs/mongochemweb-access_log" common
# This rule is used to pass session requests to the launcher
ProxyPass /session http://localhost:9000/session
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated
# if tangelo is being run as a different user.
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/
# Turn on the rewrite engine
RewriteEngine On
# This is the path the mapping file the launcher will create
RewriteMap session-to-port txt:/tmp/mapping.txt
# This is the rewrite condition. Look for anything with a sessionId= in the query part of the URL and capture the value to use below.
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]
# This does the rewrite using the mapping file and the sessionId
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]
</VirtualHost>
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:
Include conf/extra/httpd-vhosts.conf
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules: LoadModule slotmem_shm_module modules/mod_slotmem_shm.so LoadModule rewrite_module modules/mod_rewrite.so
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:
$ touch /tmp/mapping.txt
Start the httpd daemon.
$ sudo /usr/local/apache2/bin/apachectl -k start
Using Apache 2.2.X
First install the mod_python Apache module ( this can be done on Ubuntu) by issuing the following command:
$ sudo apt-get install libapache2-mod-python
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:
$ sudo pip install autobahn
The pywebosocket modul is required to listen for incoming websocket. I is installed by the following: -wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz - tar xvf mod_pywebsocket-0.7.8.tar.gz - cd mod_pywebsocket-0.7.8/src/ - python setup.py build - sudo python setup.py install
Websocket proxy configuration In order to configure the websocket proxy the following commands need to issued:
$ sudo mkdir /var/websocket_proxy $ cd /tmp $ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz $ cd /var/websocket_proxy $ tar xvf /tmp/ApacheWebsocketProxy.tgz
Update proxy.json with the following values
- "loggingConfiguration": "/var/websocket_proxy/logging.json" - "sessionMappingFile": "/var/websocket_proxy/session.map"
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.
$ sudo mv proxy.json /var/www
Apache configuration Add config to apache.conf and make sure modules are loaded
Configuring the VTK web launcher
The launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session.
The launcher can be found in the VTK source tree:
<VTK source directory>/Web/Python/launcher.py
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.
Create a file launcher.conf containing the following JSON specification:
{
"configuration": {
"host" : "localhost",
"port" : 9000,
"endpoint": "session",
"proxy_file" : "/tmp/map.txt",
"sessionURL" : "ws://${host}:${port}/ws",
"timeout" : 5,
"log_dir" : "/tmp",
"fields" : ["file", "host", "port", "updir"]
},
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],
"properties" : {
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"
},
"apps" : {
"mol" : {
"cmd" : [
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"
],
"ready_line" : "Starting factory"
}
}
}
To start the launcher issue the following command:
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf
Go to testing launcher to check that things are configured correctly.
Using Jetty Session Manager
If you are using Apache 2.2.X would will need to use the Jetty session manager. You will need to install Java (on Ubuntu) this can be done using the following command:
$ sudo apt-get install openjdk-7-jre
How you need to download and configure the session manager.
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar Configuration In order to customize and configure the Jetty session manager web server, you will need to create a configuration file, named pw-config.properties, as follows: pw.web.port=9000
- Process logs
pw.logging.dir=/tmp
- ==================================================
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service pw.mol.cmd.map=PORT:getPort
- Resources informations
pw.resources=localhost:9001-9999
- Factory
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager
- External configurations
pw.factory.proxy.adapter.file=/home/tangelo/session.map pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID
pw.process.launcher.wait.keyword=Starting factory pw.process.launcher.wait.timeout=10000
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime
The session manager can now be started using the following command:
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties
Testing your launcher configuration
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.
To test the launcher use curl issue the following request:
curl http://localhost:9000/session/123
The launcher should response with:
{"error": "No session with id: 123"}
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:
curl http://localhost/session/123
You should see the same result
Tangelo installation and configuration
Install tangelo my issuing the following command:
$sudo pip install tangelo
Now start tangelo by issuing the following command:
$tangelo start
MongoChemWeb app installation and configuration
We now need to setup the application that will be run by tangelo. As the user who will used to run tangelo issue the following commands:
$cd ~ $mkdir tangelo_html $cd tangelo_html $ git clone https://github.com/OpenChemistry/mongochemweb.git
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/
chemical.json
{
"server": "mongochem", "db": "cep", "heliumUrl": "http://mongochem:8088"
}
server - This is the hostname of the mongo database that MongoChemWeb will use to search for molecular data. The data needs to conform to this schema http://wiki.openchemistry.org/MongoChem_Schema
db - This is the database on the server to use
heliumUrl - Is the URL that the Helium similarity search can be found (optional)
conversion.json
{
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/", "cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"
}
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo.
$ cd ~/tangelo_html/mongochemweb/ $ ln -s <VTK build dir>/www vtk-web
You should now be able point your browser at http://localhost and the application should load up.