https://wiki.openchemistry.org/api.php?action=feedcontributions&user=Cjh&feedformat=atomwiki.openchemistry.org - User contributions [en]2024-03-28T13:28:22ZUser contributionsMediaWiki 1.39.3https://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=402MongoChemWeb2014-03-05T13:43:02Z<p>Cjh: /* Using the VTK web launcher */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled, and Python wrapping turned on.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON -DVTK_WRAP_PYTHON:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
For offscreen rendering you will need to build OSMesa. The Mesa 10.0.3 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 v10.0.3 release. Older or newer releases may require slightly different options. Consult ./configure --help for the details.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/10.0.3/llvmpipe<br />
<br />
$ make -j5<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before when configuring VTK:<br />
<br />
$ cmake -DVTK_Group_Web:BOOL=ON -DVTK_WRAP_PYTHON:BOOL=ON \<br />
-DVTK_USE_X:BOOL=OFF -DVTK_OPENGL_HAS_OSMESA:BOOL=ON \<br />
-DOPENGL_gl_LIBRARY:FILEPATH="" -DOPENGL_glu_LIBRARY:FILEPATH="" \<br />
-DOPENGL_INCLUDE_DIR:PATH=/opt/mesa/10.0.3/llvmpipe/include \<br />
-DOSMESA_INCLUDE_DIR:PATH=/opt/mesa/10.0.3/llvmpipe/include \<br />
-DOSMESA_LIBRARY:FILEPATH=/opt/mesa/10.0.3/llvmpipe/lib/libOSMesa.so \<br />
../VTK<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/OpenChemistry/openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, note the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / <br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Be sure to update the ProxyPass paths statements to match your configuration. For example if tangelo is going to to be run as user bob. Then / should be forwarded to http://localhost:8080/~bob/mongochemweb/<br />
<br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module.<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
<source lang="bash"><br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip.<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following.<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
The websocket proxy code now needs to be downloaded and configured.<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create a site configuration file in /etc/apache2/sites-available/, so create a file called mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo, you may need to substitute the user name you are using if its not mongochem <br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source><br />
<br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for a MongoChemWeb session. If you are using Apache 2.4.7 you should use the Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}/proxy?sessionId=${id}",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using the Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request.<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL.<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
The MongoChemWeb app requires two Python modules which can be installed as follows:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install requests<br />
$ sudo pip install pymongo<br />
</source><br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=401MongoChemWeb2014-02-28T21:52:53Z<p>Cjh: /* Configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled, and Python wrapping turned on.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON -DVTK_WRAP_PYTHON:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
For offscreen rendering you will need to build OSMesa. The Mesa 10.0.3 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 v10.0.3 release. Older or newer releases may require slightly different options. Consult ./configure --help for the details.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/10.0.3/llvmpipe<br />
<br />
$ make -j5<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before when configuring VTK:<br />
<br />
$ cmake -DVTK_Group_Web:BOOL=ON -DVTK_WRAP_PYTHON:BOOL=ON \<br />
-DVTK_USE_X:BOOL=OFF -DVTK_OPENGL_HAS_OSMESA:BOOL=ON \<br />
-DOPENGL_gl_LIBRARY:FILEPATH="" -DOPENGL_glu_LIBRARY:FILEPATH="" \<br />
-DOPENGL_INCLUDE_DIR:PATH=/opt/mesa/10.0.3/llvmpipe/include \<br />
-DOSMESA_INCLUDE_DIR:PATH=/opt/mesa/10.0.3/llvmpipe/include \<br />
-DOSMESA_LIBRARY:FILEPATH=/opt/mesa/10.0.3/llvmpipe/lib/libOSMesa.so \<br />
../VTK<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/OpenChemistry/openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, note the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / <br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Be sure to update the ProxyPass paths statements to match your configuration. For example if tangelo is going to to be run as user bob. Then / should be forwarded to http://localhost:8080/~bob/mongochemweb/<br />
<br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module.<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
<source lang="bash"><br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip.<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following.<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
The websocket proxy code now needs to be downloaded and configured.<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create a site configuration file in /etc/apache2/sites-available/, so create a file called mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo, you may need to substitute the user name you are using if its not mongochem <br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source><br />
<br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for a MongoChemWeb session. If you are using Apache 2.4.7 you should use the Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using the Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request.<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL.<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
The MongoChemWeb app requires two Python modules which can be installed as follows:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install requests<br />
$ sudo pip install pymongo<br />
</source><br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=400MongoChemWeb2014-02-28T21:52:23Z<p>Cjh: /* Configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled, and Python wrapping turned on.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON -DVTK_WRAP_PYTHON:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
For offscreen rendering you will need to build OSMesa. The Mesa 10.0.3 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 v10.0.3 release. Older or newer releases may require slightly different options. Consult ./configure --help for the details.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/10.0.3/llvmpipe<br />
<br />
$ make -j5<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before when configuring VTK:<br />
<br />
$ cmake -DVTK_Group_Web:BOOL=ON -DVTK_WRAP_PYTHON:BOOL=ON \<br />
-DVTK_USE_X:BOOL=OFF -DVTK_OPENGL_HAS_OSMESA:BOOL=ON \<br />
-DOPENGL_gl_LIBRARY:FILEPATH="" -DOPENGL_glu_LIBRARY:FILEPATH="" \<br />
-DOPENGL_INCLUDE_DIR:PATH=/opt/mesa/10.0.3/llvmpipe/include \<br />
-DOSMESA_INCLUDE_DIR:PATH=/opt/mesa/10.0.3/llvmpipe/include \<br />
-DOSMESA_LIBRARY:FILEPATH=/opt/mesa/10.0.3/llvmpipe/lib/libOSMesa.so \<br />
../VTK<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/OpenChemistry/openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, note the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / <br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Be sure to update ProxyPass paths to match your configuration. For example if tangelo is going to to be run as user bob. Then / should be forwarded to http://localhost:8080/~bob/mongochemweb/<br />
<br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module.<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
<source lang="bash"><br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip.<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following.<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
The websocket proxy code now needs to be downloaded and configured.<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create a site configuration file in /etc/apache2/sites-available/, so create a file called mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo, you may need to substitute the user name you are using if its not mongochem <br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source><br />
<br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for a MongoChemWeb session. If you are using Apache 2.4.7 you should use the Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using the Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request.<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL.<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
The MongoChemWeb app requires two Python modules which can be installed as follows:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install requests<br />
$ sudo pip install pymongo<br />
</source><br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=399MongoChemWeb2014-02-28T21:52:05Z<p>Cjh: /* Apache compile, install and configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled, and Python wrapping turned on.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON -DVTK_WRAP_PYTHON:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
For offscreen rendering you will need to build OSMesa. The Mesa 10.0.3 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 v10.0.3 release. Older or newer releases may require slightly different options. Consult ./configure --help for the details.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/10.0.3/llvmpipe<br />
<br />
$ make -j5<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before when configuring VTK:<br />
<br />
$ cmake -DVTK_Group_Web:BOOL=ON -DVTK_WRAP_PYTHON:BOOL=ON \<br />
-DVTK_USE_X:BOOL=OFF -DVTK_OPENGL_HAS_OSMESA:BOOL=ON \<br />
-DOPENGL_gl_LIBRARY:FILEPATH="" -DOPENGL_glu_LIBRARY:FILEPATH="" \<br />
-DOPENGL_INCLUDE_DIR:PATH=/opt/mesa/10.0.3/llvmpipe/include \<br />
-DOSMESA_INCLUDE_DIR:PATH=/opt/mesa/10.0.3/llvmpipe/include \<br />
-DOSMESA_LIBRARY:FILEPATH=/opt/mesa/10.0.3/llvmpipe/lib/libOSMesa.so \<br />
../VTK<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/OpenChemistry/openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, note the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / <br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Be sure to update ProxyPass paths to match your configuration. For example if tangelo is going to to be run as user bob. Then / should be forwarded to http://localhost:8080/~bob/mongochemweb/<br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module.<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
<source lang="bash"><br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip.<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following.<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
The websocket proxy code now needs to be downloaded and configured.<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create a site configuration file in /etc/apache2/sites-available/, so create a file called mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo, you may need to substitute the user name you are using if its not mongochem <br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source><br />
<br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for a MongoChemWeb session. If you are using Apache 2.4.7 you should use the Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using the Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request.<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL.<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
The MongoChemWeb app requires two Python modules which can be installed as follows:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install requests<br />
$ sudo pip install pymongo<br />
</source><br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=398MongoChemWeb2014-02-28T21:49:23Z<p>Cjh: /* MongoChemWeb app installation and configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled, and Python wrapping turned on.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON -DVTK_WRAP_PYTHON:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
For offscreen rendering you will need to build OSMesa. The Mesa 10.0.3 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 v10.0.3 release. Older or newer releases may require slightly different options. Consult ./configure --help for the details.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/10.0.3/llvmpipe<br />
<br />
$ make -j5<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before when configuring VTK:<br />
<br />
$ cmake -DVTK_Group_Web:BOOL=ON -DVTK_WRAP_PYTHON:BOOL=ON \<br />
-DVTK_USE_X:BOOL=OFF -DVTK_OPENGL_HAS_OSMESA:BOOL=ON \<br />
-DOPENGL_gl_LIBRARY:FILEPATH="" -DOPENGL_glu_LIBRARY:FILEPATH="" \<br />
-DOPENGL_INCLUDE_DIR:PATH=/opt/mesa/10.0.3/llvmpipe/include \<br />
-DOSMESA_INCLUDE_DIR:PATH=/opt/mesa/10.0.3/llvmpipe/include \<br />
-DOSMESA_LIBRARY:FILEPATH=/opt/mesa/10.0.3/llvmpipe/lib/libOSMesa.so \<br />
../VTK<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/OpenChemistry/openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module.<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
<source lang="bash"><br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip.<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following.<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
The websocket proxy code now needs to be downloaded and configured.<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create a site configuration file in /etc/apache2/sites-available/, so create a file called mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo, you may need to substitute the user name you are using if its not mongochem <br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source><br />
<br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for a MongoChemWeb session. If you are using Apache 2.4.7 you should use the Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using the Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request.<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL.<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
The MongoChemWeb app requires two Python modules which can be installed as follows:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install requests<br />
$ sudo pip install pymongo<br />
</source><br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=394MongoChemWeb2014-02-21T21:23:47Z<p>Cjh: /* Testing your launcher configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module.<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
<source lang="bash"><br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip.<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following.<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
The websocket proxy code now needs to be downloaded and configured.<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create a site configuration file in /etc/apache2/sites-available/, so create a file called mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo, you may need to substitute the user name you are using if its not mongochem <br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source><br />
<br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for a MongoChemWeb session. If you are using Apache 2.4.7 you should use the Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using the Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request.<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL.<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=393MongoChemWeb2014-02-21T21:23:24Z<p>Cjh: /* Using Jetty Session Manager */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module.<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
<source lang="bash"><br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip.<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following.<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
The websocket proxy code now needs to be downloaded and configured.<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create a site configuration file in /etc/apache2/sites-available/, so create a file called mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo, you may need to substitute the user name you are using if its not mongochem <br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source><br />
<br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for a MongoChemWeb session. If you are using Apache 2.4.7 you should use the Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using the Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=392MongoChemWeb2014-02-21T21:23:08Z<p>Cjh: /* Configuring a process launcher */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module.<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
<source lang="bash"><br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip.<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following.<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
The websocket proxy code now needs to be downloaded and configured.<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create a site configuration file in /etc/apache2/sites-available/, so create a file called mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo, you may need to substitute the user name you are using if its not mongochem <br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source><br />
<br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for a MongoChemWeb session. If you are using Apache 2.4.7 you should use the Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=391MongoChemWeb2014-02-21T21:20:59Z<p>Cjh: /* Websocket proxy configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module.<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
<source lang="bash"><br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip.<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following.<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
The websocket proxy code now needs to be downloaded and configured.<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create a site configuration file in /etc/apache2/sites-available/, so create a file called mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo, you may need to substitute the user name you are using if its not mongochem <br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source><br />
<br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=390MongoChemWeb2014-02-21T21:18:49Z<p>Cjh: /* Websocket proxy configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module.<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
<source lang="bash"><br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip.<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following.<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
The websocket proxy code now needs to be downloaded and configured.<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source><br />
<br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=389MongoChemWeb2014-02-21T21:17:55Z<p>Cjh: /* Websocket proxy configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module.<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
<source lang="bash"><br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip.<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following.<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
The websocket proxy code now needs to be downloaded and configured.<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source><br />
<br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=388MongoChemWeb2014-02-21T21:16:51Z<p>Cjh: /* Build / Installation */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command.<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module.<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
<source lang="bash"><br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip.<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following.<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source> <br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=387MongoChemWeb2014-02-21T21:16:04Z<p>Cjh: /* Build / Installation */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
<source lang="bash"><br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source> <br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=386MongoChemWeb2014-02-21T21:15:22Z<p>Cjh: /* Build / Installation */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to packaged for your distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source> <br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=385MongoChemWeb2014-02-21T21:14:34Z<p>Cjh: /* Configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it.<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules.<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this.<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source> <br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=384MongoChemWeb2014-02-21T21:13:47Z<p>Cjh: /* Building OpenChemistry */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable.<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source> <br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=383MongoChemWeb2014-02-21T21:13:34Z<p>Cjh: /* Build / Installation */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable:<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure and build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source> <br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=382MongoChemWeb2014-02-21T21:05:10Z<p>Cjh: /* Building OpenChemistry */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJSON to CML conversion executable:<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source> <br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=381MongoChemWeb2014-02-21T21:03:50Z<p>Cjh: /* Configuring process launcher */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source> <br />
== Configuring a process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=380MongoChemWeb2014-02-21T21:03:12Z<p>Cjh: </p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
$ autoreconf -fi<br />
$ ./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
$ make<br />
$ make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
$ git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
$ lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
You then need to create symlink in the enabled sites directory<br />
<br />
<source lang="bash"><br />
$ /etc/apache2/sites-enabled<br />
$ sudo ln -s ../sites-available/mongochemweb .<br />
</source> <br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=379MongoChemWeb2014-02-21T20:57:58Z<p>Cjh: /* Troubleshooting */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source><br />
If not process is found check your launcher configuration and check /tmp for logs.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=378MongoChemWeb2014-02-21T20:56:59Z<p>Cjh: /* Troubleshooting */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.<br />
* If no 3D view is display the first thing to do it check that the vtkpython processes are be launched <br />
<source lang="bash"><br />
$ ps -ef | grep vtkpython<br />
</source></div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=377MongoChemWeb2014-02-21T20:54:04Z<p>Cjh: /* Troubleshooting */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This is the place to look for errors related to visualization pipeline.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=376MongoChemWeb2014-02-21T20:49:01Z<p>Cjh: /* Troubleshooting */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
* The Tangelo log /<user running tangelo home>/.config/tangelo/tangelo.log. This is the place to log for application related errors.<br />
* When a vtkpython process is started by the launcher the stderr and stdout are redirected to a file that will appear in /tmp/<session id>.txt if you change the launcher configuration the directory may be different. This</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=375MongoChemWeb2014-02-21T20:43:16Z<p>Cjh: </p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost or http:://<yourhostname> and the application should load up.<br />
<br />
== Troubleshooting == <br />
<br />
There are three places to look for errors:<br />
<br />
* The Apache logs /usr/local/apache2/logs or /var/log/apache2. This is the place to look for error related to proxying and rewrite rules.<br />
*</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=374MongoChemWeb2014-02-21T20:36:18Z<p>Cjh: /* conversion.json */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
Once the configuration is updated you should restart Tangelo<br />
<br />
<source lang="bash"><br />
tangelo restart<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=373MongoChemWeb2014-02-21T20:34:30Z<p>Cjh: /* Using Jetty Session Manager */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X you will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochem/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochem/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/tmp/session.map<br />
pw.factory.session.url.generator.pattern=ws://hostname/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
You will need to update the hostname and path to the mongochemweb directory.<br />
<br />
The session manager can now be started using the following command:wil<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=372MongoChemWeb2014-02-21T20:31:47Z<p>Cjh: /* Websocket proxy configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/tmp/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=371MongoChemWeb2014-02-21T20:28:36Z<p>Cjh: /* Configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
<source lang="apache"><br />
Include conf/extra/httpd-vhosts.conf<br />
</source><br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=370MongoChemWeb2014-02-21T20:27:59Z<p>Cjh: /* Configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~mongochem may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=369MongoChemWeb2014-02-21T20:27:43Z<p>Cjh: /* Configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=368MongoChemWeb2014-02-21T20:26:42Z<p>Cjh: /* Apache compile, install and configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
Apache 2.4.7 has support for rewriting websocket URLs 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 custom proxy code based on mod_python.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=367MongoChemWeb2014-02-21T20:25:30Z<p>Cjh: /* Building OpenChemistry */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build#Building build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=366MongoChemWeb2014-02-21T20:24:58Z<p>Cjh: /* Building OpenChemistry */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to [http://wiki.openchemistry.org/Build build the OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=365MongoChemWeb2014-02-21T20:24:31Z<p>Cjh: /* Building OpenChemistry */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg the CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the [http://wiki.openchemistry.org/Build OpenChemistry project] starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=364MongoChemWeb2014-02-21T20:23:06Z<p>Cjh: /* chemical.json */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=363MongoChemWeb2014-02-21T20:22:05Z<p>Cjh: /* chemical.json */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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 [http://wiki.openchemistry.org/MongoChem_Schema|schema]<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=362MongoChemWeb2014-02-21T20:20:42Z<p>Cjh: /* MongoChemWeb app installation and configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
=== chemical.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
=== conversion.json ===<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=361MongoChemWeb2014-02-21T20:19:39Z<p>Cjh: /* Tangelo installation and configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
== MongoChemWeb app installation and configuration ==<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
chemical.json<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
conversion.json<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=360MongoChemWeb2014-02-21T20:15:13Z<p>Cjh: /* Tangelo installation and configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
MongoChemWeb app installation and configuration<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
chemical.json<br />
<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
conversion.json<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=359MongoChemWeb2014-02-21T20:14:43Z<p>Cjh: /* Tangelo installation and configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo pip install tangelo<br />
</source><br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
<source lang="bash" ><br />
$ tangelo start<br />
</source><br />
<br />
MongoChemWeb app installation and configuration<br />
<br />
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:<br />
<br />
<source lang="bash" ><br />
$ cd ~<br />
$ mkdir tangelo_html<br />
$ cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
</source><br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
chemical.json<br />
<br />
<br />
<source lang="JavaScript" ><br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
</source><br />
<br />
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<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
conversion.json<br />
<br />
<source lang="bash" ><br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
</source><br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
<source lang="bash" ><br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
</source><br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=358MongoChemWeb2014-02-21T20:12:35Z<p>Cjh: /* vtkpython process launcher */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== Configuring process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Using the VTK web launcher ===<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
<source lang="bash" ><br />
$ sudo apt-get install openjdk-7-jre<br />
</source><br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
<br />
<source lang="bash" ><br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
</source><br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
<source lang="bash" ><br />
curl http://localhost:9000/session/123<br />
</source><br />
<br />
The launcher should response with:<br />
<br />
<source lang="JavaScript" ><br />
{"error": "No session with id: 123"}<br />
</source><br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
<source lang="bash" ><br />
curl http://localhost/session/123<br />
</source><br />
<br />
You should see the same result<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo my issuing the following command:<br />
<br />
$sudo pip install tangelo<br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
$tangelo start<br />
<br />
<br />
MongoChemWeb app installation and configuration<br />
<br />
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:<br />
<br />
$cd ~<br />
$mkdir tangelo_html<br />
$cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
chemical.json<br />
<br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
<br />
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<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
conversion.json<br />
<br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
<br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=357MongoChemWeb2014-02-21T20:04:21Z<p>Cjh: /* Websocket proxy configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
== vtkpython process launcher ==<br />
<br />
A launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session. If you are using Apache 2.4.7 you should use Python launcher that comes with VTK, otherwise you will need to use the Jetty based session manager that will do the same job.<br />
<br />
=== Configuring the VTK web launcher ===<br />
The launcher is <br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
=== Using Jetty Session Manager ===<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
$ sudo apt-get install openjdk-7-jre<br />
<br />
How you need to download and configure the session manager.<br />
<br />
<source lang="Java"><br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
</source><br />
<br />
The session manager can now be started using the following command:<br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
<br />
<br />
=== Testing your launcher configuration ===<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
curl http://localhost:9000/session/123<br />
<br />
The launcher should response with:<br />
<br />
{"error": "No session with id: 123"}<br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
curl http://localhost/session/123<br />
<br />
You should see the same result<br />
<br />
<br />
== Tangelo installation and configuration ==<br />
<br />
Install tangelo my issuing the following command:<br />
<br />
$sudo pip install tangelo<br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
$tangelo start<br />
<br />
<br />
MongoChemWeb app installation and configuration<br />
<br />
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:<br />
<br />
$cd ~<br />
$mkdir tangelo_html<br />
$cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
chemical.json<br />
<br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
<br />
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<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
conversion.json<br />
<br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
<br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=356MongoChemWeb2014-02-21T19:58:38Z<p>Cjh: /* Websocket proxy configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to create site configuration file in /etc/apache2/sites-available/, so create a file call mongochemweb contain the following configuration:<br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# Replace with real hostname<br />
ServerName hostname<br />
DocumentRoot /var/websocket_proxy<br />
# Jetty session manager<br />
ProxyPass /session http://localhost:9000/sessionmgr/paraview ttl=500<br />
# Tangelo<br />
ProxyPass / http://localhost:8080/~mongochem/mongochemweb/<br />
<Directory /var/websocket_proxy><br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
AddHandler mod_python .py<br />
PythonHandler mod_python.publisher<br />
PythonDebug On<br />
</Directory><br />
ErrorLog logs/mongochemweb-error.log<br />
CustomLog logs/mongochemweb-access.log <br />
</VirtualHost><br />
<br />
</source><br />
<br />
Configuring the VTK web launcher<br />
The launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session.<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
Using Jetty Session Manager<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
$ sudo apt-get install openjdk-7-jre<br />
<br />
How you need to download and configure the session manager.<br />
<br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
<br />
<br />
The session manager can now be started using the following command:<br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
<br />
<br />
Testing your launcher configuration<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
curl http://localhost:9000/session/123<br />
<br />
The launcher should response with:<br />
<br />
{"error": "No session with id: 123"}<br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
curl http://localhost/session/123<br />
<br />
You should see the same result<br />
<br />
<br />
Tangelo installation and configuration<br />
<br />
Install tangelo my issuing the following command:<br />
<br />
$sudo pip install tangelo<br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
$tangelo start<br />
<br />
<br />
MongoChemWeb app installation and configuration<br />
<br />
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:<br />
<br />
$cd ~<br />
$mkdir tangelo_html<br />
$cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
chemical.json<br />
<br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
<br />
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<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
conversion.json<br />
<br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
<br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=355MongoChemWeb2014-02-21T19:51:16Z<p>Cjh: /* Build / Installation */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Ensure that the correct link was create to load the module:<br />
<br />
<source lang="bash"><br />
$ ls -l /etc/apache2/mods-enabled/python.load<br />
</source><br />
<br />
This should give:<br />
<br />
lrwxrwxrwx 1 root root 29 Sep 4 14:50 /etc/apache2/mods-enabled/python.load -> ../mods-available/python.load<br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to <br />
<br />
Configuring the VTK web launcher<br />
The launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session.<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
Using Jetty Session Manager<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
$ sudo apt-get install openjdk-7-jre<br />
<br />
How you need to download and configure the session manager.<br />
<br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
<br />
<br />
The session manager can now be started using the following command:<br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
<br />
<br />
Testing your launcher configuration<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
curl http://localhost:9000/session/123<br />
<br />
The launcher should response with:<br />
<br />
{"error": "No session with id: 123"}<br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
curl http://localhost/session/123<br />
<br />
You should see the same result<br />
<br />
<br />
Tangelo installation and configuration<br />
<br />
Install tangelo my issuing the following command:<br />
<br />
$sudo pip install tangelo<br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
$tangelo start<br />
<br />
<br />
MongoChemWeb app installation and configuration<br />
<br />
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:<br />
<br />
$cd ~<br />
$mkdir tangelo_html<br />
$cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
chemical.json<br />
<br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
<br />
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<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
conversion.json<br />
<br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
<br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=354MongoChemWeb2014-02-21T19:48:45Z<p>Cjh: /* Websocket proxy configuration */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
The following lines need to be added to /etc/apache2/apache2.conf to configure the mod_python module<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /var/websocket_proxy/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
<br />
<br />
You will also need to <br />
<br />
Configuring the VTK web launcher<br />
The launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session.<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
Using Jetty Session Manager<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
$ sudo apt-get install openjdk-7-jre<br />
<br />
How you need to download and configure the session manager.<br />
<br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
<br />
<br />
The session manager can now be started using the following command:<br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
<br />
<br />
Testing your launcher configuration<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
curl http://localhost:9000/session/123<br />
<br />
The launcher should response with:<br />
<br />
{"error": "No session with id: 123"}<br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
curl http://localhost/session/123<br />
<br />
You should see the same result<br />
<br />
<br />
Tangelo installation and configuration<br />
<br />
Install tangelo my issuing the following command:<br />
<br />
$sudo pip install tangelo<br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
$tangelo start<br />
<br />
<br />
MongoChemWeb app installation and configuration<br />
<br />
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:<br />
<br />
$cd ~<br />
$mkdir tangelo_html<br />
$cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
chemical.json<br />
<br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
<br />
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<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
conversion.json<br />
<br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
<br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=353MongoChemWeb2014-02-21T19:43:13Z<p>Cjh: /* Build / Installation */</p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
Once Apache is installed the mod_python Apache module needs to be installed ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
Apache configuration<br />
Add config to apache.conf and make sure modules are loaded<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /home/tangelo/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
Configuring the VTK web launcher<br />
The launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session.<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
Using Jetty Session Manager<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
$ sudo apt-get install openjdk-7-jre<br />
<br />
How you need to download and configure the session manager.<br />
<br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
<br />
<br />
The session manager can now be started using the following command:<br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
<br />
<br />
Testing your launcher configuration<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
curl http://localhost:9000/session/123<br />
<br />
The launcher should response with:<br />
<br />
{"error": "No session with id: 123"}<br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
curl http://localhost/session/123<br />
<br />
You should see the same result<br />
<br />
<br />
Tangelo installation and configuration<br />
<br />
Install tangelo my issuing the following command:<br />
<br />
$sudo pip install tangelo<br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
$tangelo start<br />
<br />
<br />
MongoChemWeb app installation and configuration<br />
<br />
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:<br />
<br />
$cd ~<br />
$mkdir tangelo_html<br />
$cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
chemical.json<br />
<br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
<br />
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<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
conversion.json<br />
<br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
<br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=352MongoChemWeb2014-02-21T19:41:54Z<p>Cjh: </p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
Old versions of Apache are likely to package for you distribution for example Apache 2.2 can be install on Ubuntu LTS using the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install apache2<br />
</source><br />
<br />
First install the mod_python Apache module ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
Apache configuration<br />
Add config to apache.conf and make sure modules are loaded<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /home/tangelo/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
Configuring the VTK web launcher<br />
The launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session.<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
Using Jetty Session Manager<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
$ sudo apt-get install openjdk-7-jre<br />
<br />
How you need to download and configure the session manager.<br />
<br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
<br />
<br />
The session manager can now be started using the following command:<br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
<br />
<br />
Testing your launcher configuration<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
curl http://localhost:9000/session/123<br />
<br />
The launcher should response with:<br />
<br />
{"error": "No session with id: 123"}<br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
curl http://localhost/session/123<br />
<br />
You should see the same result<br />
<br />
<br />
Tangelo installation and configuration<br />
<br />
Install tangelo my issuing the following command:<br />
<br />
$sudo pip install tangelo<br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
$tangelo start<br />
<br />
<br />
MongoChemWeb app installation and configuration<br />
<br />
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:<br />
<br />
$cd ~<br />
$mkdir tangelo_html<br />
$cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
chemical.json<br />
<br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
<br />
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<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
conversion.json<br />
<br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
<br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=351MongoChemWeb2014-02-21T19:32:54Z<p>Cjh: </p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
First install the mod_python Apache module ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebsocket module is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
Apache configuration<br />
Add config to apache.conf and make sure modules are loaded<br />
<br />
<source lang="apache"><br />
PythonPath "sys.path+['/usr/local/lib/python2.7/dist-packages/mod_pywebsocket']"<br />
PythonOption mod_pywebsocket.handler_root /home/tangelo/apache-websocket<br />
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler<br />
PythonInterpreter main_interpreter<br />
</source><br />
<br />
Configuring the VTK web launcher<br />
The launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session.<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
Using Jetty Session Manager<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
$ sudo apt-get install openjdk-7-jre<br />
<br />
How you need to download and configure the session manager.<br />
<br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
<br />
<br />
The session manager can now be started using the following command:<br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
<br />
<br />
Testing your launcher configuration<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
curl http://localhost:9000/session/123<br />
<br />
The launcher should response with:<br />
<br />
{"error": "No session with id: 123"}<br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
curl http://localhost/session/123<br />
<br />
You should see the same result<br />
<br />
<br />
Tangelo installation and configuration<br />
<br />
Install tangelo my issuing the following command:<br />
<br />
$sudo pip install tangelo<br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
$tangelo start<br />
<br />
<br />
MongoChemWeb app installation and configuration<br />
<br />
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:<br />
<br />
$cd ~<br />
$mkdir tangelo_html<br />
$cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
chemical.json<br />
<br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
<br />
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<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
conversion.json<br />
<br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
<br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjhhttps://wiki.openchemistry.org/index.php?title=MongoChemWeb&diff=350MongoChemWeb2014-02-21T18:02:30Z<p>Cjh: </p>
<hr />
<div>The following steps are required for the deployment of MongoChemWeb: <br />
<br />
== Building VTK with web support ==<br />
<br />
VTK needs to be configured with the Web group enabled.<br />
<br />
<source lang="bash"><br />
$ git clone git://vtk.org/VTK.git VTK<br />
$ mkdir VTK-build<br />
$ cd VTK-build<br />
$ cmake -DVTK_Group_Web:BOOL=ON ../VTK <br />
$ make<br />
</source><br />
<br />
=== Building with Mesa ===<br />
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.<br />
<br />
<source lang="bash"><br />
autoreconf -fi<br />
./configure \<br />
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \<br />
--disable-xvmc \<br />
--disable-glx \<br />
--disable-dri \<br />
--with-dri-drivers="" \<br />
--with-gallium-drivers="swrast" \<br />
--enable-texture-float \<br />
--disable-shared-glapi \<br />
--disable-egl \<br />
--with-egl-platforms="" \<br />
--enable-gallium-osmesa \<br />
--enable-gallium-llvm=yes \<br />
--with-llvm-shared-libs \<br />
--prefix=/opt/mesa/9.2.2/llvmpipe<br />
<br />
make<br />
make install<br />
</source><br />
<br />
Some explanation of these options:<br />
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.<br />
--enable-texture-float Floating point textures are disabled by default due to patent restrictions. They must be enabled for many advanced VTK algorithms.<br />
To use Mesa with VTK you will need to set the following options before building VTK:<br />
<br />
VTK_USE_X OFF<br />
VTK_OPENGL_HAS_OSMESA ON<br />
<br />
== Building OpenChemistry ==<br />
<br />
Clone the OpenChemistry repository containg teh CJOSN to CML conversion executable:<br />
<br />
<source lang="bash"><br />
git clone --recursive https://github.com/cjh1/mongochemweb-openchemistry.git openchemistry<br />
</source><br />
<br />
Now follow instruction to build the OpenChemistry project: http://wiki.openchemistry.org/Build starting at the Build step.<br />
<br />
== Apache compile, install and configuration ==<br />
<br />
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.<br />
<br />
=== Using Apache 2.4.7 ===<br />
==== Build / Installation ====<br />
<br />
Unless Apache 2.4.7 is packaged your distribution you will need to compile from source.<br />
<br />
Obtain the necessary source tarballs. You will need httpd source, as well as apr and apr-util sources.<br />
<br />
<source lang="bash"><br />
$ wget http://mirrors.sonic.net/apache/httpd/httpd-2.4.7.tar.gz -O httpd.tgz<br />
$ wget http://apache.petsads.us/apr/apr-1.5.0.tar.gz -O apr.tgz<br />
$ wget http://apache.petsads.us/apr/apr-util-1.5.3.tar.gz -O apr-util.tgz<br />
</source><br />
<br />
Now unpack everything in the right places.<br />
<br />
<source lang="bash"><br />
$ mkdir apache-2.4.7-src<br />
$ cd apache-2.4.7-src<br />
$ tar zxvf ../httpd.tgz<br />
$ cd httpd-2.4.7/srclib<br />
$ tar zxvf ../../../apr.tgz<br />
$ mv apr-1.5.0 apr<br />
$ tar zxvf ../../../apr-util.tgz<br />
$ mv apr-util-1.5.3 apr-util<br />
</source><br />
<br />
Now configure the Apache build.<br />
<br />
<source lang="bash"><br />
$ cd apache-2.4.7-src/httpd-2.4.7<br />
$ ./configure --with-included-apr --enable-proxy<br />
$ make<br />
$ sudo make install<br />
</source><br />
<br />
==== Configuration ====<br />
<br />
Add a virtual host to the httpd-vhosts.conf file, which will be located in the directory /usr/local/apache2/conf/extra/. <br />
<br />
<source lang="apache"><br />
<VirtualHost *:80><br />
# The hostname need to be updated<br />
ServerName hostname<br />
ServerAdmin webmaster@example-host.example.com<br />
ErrorLog "logs/mongochemweb-error_log"<br />
CustomLog "logs/mongochemweb-access_log" common<br />
# This rule is used to pass session requests to the launcher<br />
ProxyPass /session http://localhost:9000/session<br />
# Proxy rest of traffic to tangelo, not the ~tangelo may need to be updated<br />
# if tangelo is being run as a different user.<br />
ProxyPass / http://localhost:8080/~tangelo/mongochemweb/<br />
# Turn on the rewrite engine<br />
RewriteEngine On<br />
# This is the path the mapping file the launcher will create<br />
RewriteMap session-to-port txt:/tmp/mapping.txt<br />
# 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.<br />
RewriteCond %{QUERY_STRING} ^sessionId=(.*)$ [NC]<br />
# This does the rewrite using the mapping file and the sessionId<br />
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/ws [P]<br />
</VirtualHost><br />
</source><br />
<br />
Include this virtual host in the main httpd configuration file. Find the following line in /usr/local/apache2/conf/httpd.conf and uncomment it:<br />
<br />
Include conf/extra/httpd-vhosts.conf<br />
<br />
Find the following lines in the httpd.conf file and uncomment them in order to load some necessary modules:<br />
<br />
<source lang="apache"><br />
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so<br />
LoadModule rewrite_module modules/mod_rewrite.so<br />
</source><br />
<br />
We need to ensure the mapping file exists before starting Apache. Issue the following command to this:<br />
<br />
<source lang="bash"><br />
$ touch /tmp/mapping.txt<br />
</source><br />
<br />
Start the httpd daemon.<br />
<br />
<source lang="bash"><br />
$ sudo /usr/local/apache2/bin/apachectl -k start<br />
</source><br />
<br />
=== Using Apache 2.2.X ===<br />
<br />
==== Build / Installation ====<br />
<br />
First install the mod_python Apache module ( this can be done on Ubuntu) by issuing the following command:<br />
<br />
<source lang="bash"><br />
$ sudo apt-get install libapache2-mod-python<br />
</source><br />
<br />
Autobahn is needed by the proxy to make websocket connections to the backend. It can be install using pip:<br />
<br />
<source lang="bash"><br />
$ sudo pip install autobahn<br />
</source><br />
<br />
The pywebosocket modul is required to listen for incoming websocket. It is installed by the following:<br />
<br />
<source lang="bash"><br />
$ wget http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.7.8.tar.gz<br />
$ tar xvf mod_pywebsocket-0.7.8.tar.gz<br />
$ cd mod_pywebsocket-0.7.8/src/<br />
$ python setup.py build<br />
$ sudo python setup.py install<br />
</source><br />
<br />
==== Websocket proxy configuration ====<br />
In order to configure the websocket proxy the following commands need to issued:<br />
<br />
<source lang="bash"><br />
$ sudo mkdir /var/websocket_proxy<br />
$ cd /tmp<br />
$ wget http://pvw.kitware.com/guides/apache_setup/data/ApacheWebsocketProxy.tgz<br />
$ cd /var/websocket_proxy<br />
$ tar xvf /tmp/ApacheWebsocketProxy.tgz<br />
</source><br />
<br />
Update proxy.json with the following values<br />
<br />
"loggingConfiguration": "/var/websocket_proxy/logging.json"<br />
"sessionMappingFile": "/var/websocket_proxy/session.map"<br />
<br />
The proxy configuration needs to be in home directory of the user who runs Apache. This is usually /var/www.<br />
<br />
<source lang="bash"><br />
$ sudo mv proxy.json /var/www<br />
</source><br />
<br />
Apache configuration<br />
Add config to apache.conf and make sure modules are loaded<br />
<br />
<source lang="apache"><br />
<br />
</source><br />
<br />
Configuring the VTK web launcher<br />
The launcher is used to start python processes that provide the visualization pipeline for MongoChemWeb session.<br />
<br />
The launcher can be found in the VTK source tree:<br />
<br />
<VTK source directory>/Web/Python/launcher.py<br />
<br />
The launcher takes a configuration file specifies the parameters to use when launching the vtkpython processes.<br />
<br />
Create a file launcher.conf containing the following JSON specification:<br />
<br />
<source lang="JavaScript"><br />
{<br />
<br />
"configuration": {<br />
"host" : "localhost",<br />
"port" : 9000,<br />
"endpoint": "session",<br />
"proxy_file" : "/tmp/map.txt",<br />
"sessionURL" : "ws://${host}:${port}/ws",<br />
"timeout" : 5,<br />
"log_dir" : "/tmp",<br />
"fields" : ["file", "host", "port", "updir"]<br />
},<br />
<br />
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9999] } ],<br />
<br />
<br />
"properties" : {<br />
"mongochemweb_dir": "/home/cjh/tangelo_html/mongochemweb",<br />
"python_exec" : "/home/cjh/work/build/VTK/bin/vtkpython"<br />
},<br />
<br />
<br />
"apps" : {<br />
"mol" : {<br />
"cmd" : [<br />
"${python_exec}", "${mongochemweb_dir}/service/vtk_web_molecule.py", "--port", "$port"<br />
],<br />
"ready_line" : "Starting factory"<br />
}<br />
}<br />
}<br />
</source><br />
<br />
To start the launcher issue the following command:<br />
<br />
$ python <VTK source directory>/Web/Python/launcher.py launcher.conf<br />
<br />
Go to testing launcher to check that things are configured correctly.<br />
<br />
Using Jetty Session Manager<br />
<br />
If you are using Apache 2.2.X would will need to use the Jetty session manager.<br />
You will need to install Java (on Ubuntu) this can be done using the following command:<br />
<br />
$ sudo apt-get install openjdk-7-jre<br />
<br />
How you need to download and configure the session manager.<br />
<br />
$ wget http://paraview.org/files/dependencies/ParaViewWeb/JettySessionManager-Server-1.0.jar<br />
Configuration<br />
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:<br />
pw.web.port=9000<br />
# Process logs<br />
pw.logging.dir=/tmp<br />
# ==================================================<br />
pw.mol.cmd=<VTK build dir>/bin/vtkpython /home/mongochemweb/tangelo_html/mongochemweb/service/vtk_web_molecule.py --port PORT<br />
pw.mol.cmd.run.dir=/home/mongochemweb/tangelo_html/mongochemweb/service<br />
pw.mol.cmd.map=PORT:getPort<br />
<br />
# Resources informations<br />
pw.resources=localhost:9001-9999<br />
<br />
# Factory<br />
pw.factory.proxy.adapter=com.kitware.paraviewweb.external.JsonFileProxyConnectionAdapter<br />
pw.factory.session.url.generator=com.kitware.paraviewweb.external.GenericSessionURLGenerator<br />
pw.factory.resource.manager=com.kitware.paraviewweb.external.SimpleResourceManager<br />
pw.factory.visualization.launcher=com.kitware.paraviewweb.external.ProcessLauncher<br />
pw.factory.websocket.proxy=com.kitware.paraviewweb.external.SimpleWebSocketProxyManager<br />
pw.factory.session.manager=com.kitware.paraviewweb.external.MemorySessionManager<br />
<br />
# External configurations<br />
pw.factory.proxy.adapter.file=/home/tangelo/session.map<br />
pw.factory.session.url.generator.pattern=ws://data.openchemistry.org/proxy?sessionId=SESSION_ID<br />
<br />
pw.process.launcher.wait.keyword=Starting factory<br />
pw.process.launcher.wait.timeout=10000<br />
<br />
pw.session.public.fields=id,sessionURL,name,description,sessionManagerURL,application,idleTimeout,startTime<br />
<br />
<br />
The session manager can now be started using the following command:<br />
java -jar JettySessionManager-Server-1.0.jar /path_to_your_config_file/pw-config.properties<br />
<br />
<br />
Testing your launcher configuration<br />
Regardless of the launcher you are using you can use the following procedure to test that it is responsing to requests.<br />
<br />
To test the launcher use curl issue the following request:<br />
<br />
curl http://localhost:9000/session/123<br />
<br />
The launcher should response with:<br />
<br />
{"error": "No session with id: 123"}<br />
<br />
Now check that the launcher requests are successfully proxies through Apache by issuing the same request to the external URL:<br />
<br />
curl http://localhost/session/123<br />
<br />
You should see the same result<br />
<br />
<br />
Tangelo installation and configuration<br />
<br />
Install tangelo my issuing the following command:<br />
<br />
$sudo pip install tangelo<br />
<br />
Now start tangelo by issuing the following command:<br />
<br />
$tangelo start<br />
<br />
<br />
MongoChemWeb app installation and configuration<br />
<br />
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:<br />
<br />
$cd ~<br />
$mkdir tangelo_html<br />
$cd tangelo_html<br />
$ git clone https://github.com/OpenChemistry/mongochemweb.git<br />
<br />
The configuration on mongochemweb needs to be adjust to machine the installation. The configuration file an be found in mongochemweb/config/<br />
<br />
chemical.json<br />
<br />
{<br />
"server": "mongochem",<br />
"db": "cep",<br />
"heliumUrl": "http://mongochem:8088"<br />
}<br />
<br />
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<br />
<br />
db - This is the database on the server to use<br />
<br />
heliumUrl - Is the URL that the Helium similarity search can be found (optional)<br />
<br />
conversion.json<br />
<br />
{<br />
"baseUrl": "http://localhost:8080/~cjh/mongochemweb/",<br />
"cjsonToCmlPath": "<OpenChemistry build dir>/avogadrolibs/bin/avocjsontocml"<br />
}<br />
<br />
baseUrl - This is the URL as which the MongoChemWeb app is be served by tangelo<br />
cjsonToCmlPath - This is the path to executable used to convert from CJSON to CML which we compiled earilier.<br />
<br />
Now we need to create a symlink to ensure that the VTK web client can be found by tangelo. <br />
<br />
$ cd ~/tangelo_html/mongochemweb/<br />
$ ln -s <VTK build dir>/www vtk-web<br />
<br />
<br />
You should now be able point your browser at http://localhost and the application should load up.</div>Cjh