Commit 39cd211d authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

no longer use Xvfb.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@43123 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 15d6994c
1.2.2 (2010-02-07)
==================
- No longer use Xvfb.
1.2.1 (2010-01-21)
==================
- Improve ERP5 compatibility.
......
......@@ -6,34 +6,12 @@ Install Cloudooo
Warnings:
- you must have installed setuptools>=0.6c11 in this python.
Install Dependencies in Mandriva
================================
Install LibreOffice / OpenOffice.org
====================================
$ urpmi xvfb # System Dependencies
Install OpenOffice.org
======================
Was used for testing the package's official openoffice.org. Follow these steps to install:
Download Package from the official site
---------------------------------------
x86_32
----
$ wget http://download.services.openoffice.org/files/stable/3.2.0/OOo_3.2.0_LinuxIntel_install_wJRE_en-US.tar.gz
x86_64
------
$ wget http://download.services.openoffice.org/files/stable/3.2.0/OOo_3.2.0_LinuxX86-64_install_wJRE_en-US.tar.gz
Unpack the tar.gz and Install
-----------------------------
$ tar zxvf OOo_3.2.0_LinuxX86-64_install_wJRE_en-US.tar.gz
$ cd OOO320_m12_native_packed-1_en-US.9483/RPMS
$ rpm -i *.rpm # install all packages together
The instalation is in /opt
Install LibreOffice or OpenOffice.org.
- http://www.libreoffice.org/download/
- http://download.openoffice.org/
Create Configuration File
=========================
......@@ -43,8 +21,8 @@ Create Configuration File
The next step is define some attributes in cloudooo.conf:
- working_path - folder to run the application. This folder need be created.
- uno_path - full path to UNO library;
- soffice_binary_path - full path to soffice.bin;
- uno_path - folder where UNO library is installed (ex. /opt/libreoffice/basis-link/program/)
- soffice_binary_path - folder where soffice.bin is installed (ex. /opt/libreoffice/program/)
Run Application
===============
......@@ -67,45 +45,38 @@ stopped correctly.
Cloudooo Description
=====================
- XMLRPC + WSGI will be one bridge for easy access OpenOffice.org. This will implement one XMLRPC server into WSGI (Paster).
- PyUno is used to connect to OpenOffice.org stated with open socket. The features will be handled all by pyuno.
- XMLRPC + WSGI will be one bridge for easy access to LibreOffice / OpenOffice.org. This will implement one XMLRPC server into WSGI (Paster).
- Xvfb is used to run Openoffice.org. This is controlled by Daemon(cloudooo).
- PyUno is used to connect to LibreOffice / OpenOffice.org stated with open socket. The features will be handled all by pyuno.
- Only a process will have access to OpenOffice.org by time.
- Only a process will have access to LibreOffice / OpenOffice.org by time.
- All clients receive the same object(proxy) when connects with XMLRPC Server.
Xvfb and OpenOffice
Managing LibreOffice / OpenOffice.org process
- configure and start Xvfb;
- Use a single Xvfb;
- the xvfb will be started with the XMLRPC Server;
- When start the Daemon(cloudooo), it configures Xvfb, next opens the openoffice(with pyuno) and start XMLRPC Server;
- control Xvfb;
- start openoffice;
- Pyuno start the openoffice processes and the communication is through sockets;
- Openoffice processes run in brackground and in virtual display;
- control openoffice;
- The socket can't lose the connection, if this occurs should kill the process and submit again the file;
- start 'soffice.bin';
- Pyuno start 'soffice.bin' processes and the communication is through sockets;
- 'soffice.bin' processes run in brackground;
- control 'soffice.bin';
- If the socket lose the connection, cloudooo kills the process, restartes processes and submit again the file;
XMLRPC Server - XMLRPC + WSGI
-----------------------------
- Send document to openoffice and return the document converted with metadata;
- XMLRPC receives a file and connects to a openoffice by pyuno;
- The pyuno opens a new openoffice, write, add metadata and returns the document edited or converted to xmlrpc and it return the document to the user;
- When finalize the use of openoffice, should make sure that it was finalized;
- Send document to 'soffice.bin' and return the document converted with metadata;
- XMLRPC receives a file and connects to 'soffice.bin' process by pyuno;
- The pyuno opens a new document, write, add metadata and returns the document edited or converted to xmlrpc and it return the document to the user;
- When finalize the use of 'soffice.bin', should make sure that it was finalized;
- Export to another format;
- Invite document and return metadata only;
- Edit metadata of the document;
- Problems and possible solution
- OpenOffice is stalled;
- finalize the process, start openoffice and submit the document again(without restart the cloudooo);
- Openoffice is crashed;
- finalize the process, verify if all the process was killed, start openoffice and submit the document again(without restart the cloudooo)
- OpenOffice received the document and stalled;
- if openoffice isn't responding, kill the process and start
- 'soffice.bin' is stalled;
- finalize the process, start 'soffice.bin' and submit the document again(without restart the cloudooo);
- 'soffice.bin' is crashed;
- finalize the process, verify if all the process was killed, start 'soffice.bin' and submit the document again(without restart the cloudooo)
- 'soffice.bin' received the document and stalled;
- if 'soffice.bin' isn't responding, kill the process and start
- The document that was sent is corrupt;
- write in log the error and verify that the process aren't in memory
......@@ -60,18 +60,16 @@ class Application(object):
Process(process_pid).kill()
delattr(self, "process")
def loadSettings(self, hostname, port, path_run_dir, display_id, **kwargs):
def loadSettings(self, hostname, port, path_run_dir, **kwargs):
"""Define attributes for application instance
Keyword arguments:
hostname -- Host to start the instance.
port -- Expected a int number.
path_run_dir -- Full path to create the enviroment.
display_id -- Display to open the OpenOffice.
"""
self.hostname = hostname
self.port = port
self.path_run_dir = path_run_dir
self.display_id = display_id
self.timeout = kwargs.get('start_timeout', 20)
def restart(self):
......
......@@ -33,7 +33,6 @@ from subprocess import Popen, PIPE
from threading import Lock
from zope.interface import implements
from application import Application
from cloudooo.handler.ooo.application.xvfb import xvfb
from cloudooo.interfaces.lockable import ILockable
from cloudooo.utils.utils import logger, convertStringToBool
from cloudooo.handler.ooo.utils.utils import waitStartDaemon, \
......@@ -83,7 +82,7 @@ class OpenOffice(Application):
"""Define request attribute as 0"""
self.request = 0
def loadSettings(self, hostname, port, path_run_dir, display_id,
def loadSettings(self, hostname, port, path_run_dir,
office_binary_path, uno_path, default_language,
environment_dict=None, **kw):
"""Method to load the configuratio to control one OpenOffice Instance
......@@ -94,7 +93,7 @@ class OpenOffice(Application):
"""
if environment_dict is None:
environment_dict = {}
Application.loadSettings(self, hostname, port, path_run_dir, display_id)
Application.loadSettings(self, hostname, port, path_run_dir)
self.office_binary_path = office_binary_path
self.uno_path = uno_path
self.default_language = default_language
......@@ -131,33 +130,28 @@ class OpenOffice(Application):
def start(self):
"""Start Instance."""
if not xvfb.status():
xvfb.restart()
self.path_user_installation = join(self.path_run_dir, \
"cloudooo_instance_%s" % self.port)
if exists(self.path_user_installation):
removeDirectory(self.path_user_installation)
# Create command with all parameters to start the instance
self.command = [join(self.office_binary_path, self._bin_soffice),
'-headless',
'-invisible',
'-nologo',
'-nodefault',
'-norestore',
'-nofirststartwizard',
'-accept=socket,host=%s,port=%d;urp;' % (self.hostname, self.port),
'-display',
':%s' % self.display_id,
'-env:UserInstallation=file://%s' % self.path_user_installation,
'-language=%s' % self.default_language,
]
# To run the instance OOo is need a environment. So, the "DISPLAY" of Xvfb
# is passed to env and the environment customized is passed to the process
# To run soffice.bin, several environment variables should be set.
env = self.environment_dict.copy()
env["LANG"] = "UTF-8"
env["HOME"] = self.path_user_installation
env["TMP"] = self.path_user_installation
env["TMPDIR"] = self.path_user_installation
env["DISPLAY"] = ":%s" % self.display_id
self._startProcess(self.command, env)
self._cleanRequest()
Application.start(self)
......
##############################################################################
#
# Copyright (c) 2009-2010 Nexedi SA and Contributors. All Rights Reserved.
# Gabriel M. Monnerat <gabriel@tiolive.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from subprocess import Popen, PIPE
from cloudooo.utils.utils import logger
from cloudooo.handler.ooo.utils.utils import waitStartDaemon, remove_file
from zope.interface import implements
from application import Application
from cloudooo.interfaces.application import IApplication
from os.path import exists
class Xvfb(Application):
"""Start and control Xvfb. It is used to open/run
instances OpenOffice.
"""
implements(IApplication)
name = "xvfb"
def loadSettings(self, hostname, port, path_run_dir, display_id, **kwargs):
"""Method to load the configuration to run and monitoring the Xvfb.
Keyword Arguments:
virtual_screen -- the display number
"""
Application.loadSettings(self, hostname, port, path_run_dir, display_id)
self.virtual_screen = kwargs.get('virtual_screen', '0')
self.process_name = "Xvfb"
def start(self):
"""Method to start Virtual Frame Buffer."""
self.command = ["Xvfb", "-ac", ":%s" % self.display_id, \
"-screen", self.virtual_screen, "800x600x16", \
"-fbdir", self.path_run_dir]
self.process = Popen(self.command, close_fds=True)
waitStartDaemon(self, self.timeout)
Application.start(self)
logger.debug("Xvfb pid - %s" % self.pid())
def stop(self):
"""Stop Xvfb processes and remove lock file in file system"""
Application.stop(self)
lock_filepath = '/tmp/.X%s-lock' % self.display_id
if exists(lock_filepath):
remove_file(lock_filepath)
display_filepath = '/tmp/X11/X%s' % self.display_id
if exists(display_filepath):
remove_file(display_filepath)
xvfb = Xvfb()
......@@ -33,7 +33,6 @@ from base64 import decodestring, encodestring
from os import environ, path
from subprocess import Popen, PIPE
from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.handler.ooo.application.xvfb import xvfb
from zope.interface import implements
from cloudooo.interfaces.handler import IHandler
from cloudooo.handler.ooo.mimemapper import mimemapper
......@@ -116,7 +115,6 @@ class OOHandler:
def _callUnoConverter(self, *feature_list, **kw):
""" """
if not openoffice.status():
xvfb.restart()
openoffice.start()
command_list = self._getCommand(*feature_list, **kw)
stdout, stderr = self._subprocess(command_list)
......
......@@ -31,7 +31,6 @@ import sys
from ConfigParser import ConfigParser
from os import path, mkdir
from os import environ, putenv
from cloudooo.handler.ooo.application.xvfb import xvfb
from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.handler.ooo.utils.utils import waitStartDaemon
from cloudooo.handler.ooo.mimemapper import mimemapper
......@@ -60,9 +59,6 @@ def startFakeEnvironment(start_openoffice=True, conf_path=None):
config.read(conf_path)
uno_path = config.get("app:main", "uno_path")
working_path = config.get("app:main", "working_path")
virtual_display_id = int(config.get("app:main", "virtual_display_id"))
virtual_display_port_int = int(config.get("app:main",
"virtual_display_port"))
hostname = config.get("server:main", "host")
openoffice_port = int(config.get("app:main", "openoffice_port"))
office_binary_path = config.get("app:main", "office_binary_path")
......@@ -82,14 +78,6 @@ def startFakeEnvironment(start_openoffice=True, conf_path=None):
not environ.has_key('URE_BOOTSTRAP'):
putenv('URE_BOOTSTRAP', 'vnd.sun.star.pathname:%s' % fundamentalrc_file)
xvfb.loadSettings(hostname,
virtual_display_port_int,
working_path,
virtual_display_id,
virtual_screen='1')
xvfb.start()
waitStartDaemon(xvfb, 10)
if start_openoffice:
default_language = config.get('app:main',
'openoffice_user_interface_language', False,
......@@ -97,7 +85,6 @@ def startFakeEnvironment(start_openoffice=True, conf_path=None):
openoffice.loadSettings(hostname,
openoffice_port,
working_path,
virtual_display_id,
office_binary_path,
uno_path,
default_language)
......@@ -109,16 +96,12 @@ def startFakeEnvironment(start_openoffice=True, conf_path=None):
if not mimemapper.isLoaded():
mimemapper.loadFilterList(hostname, port, **kw)
openoffice.release()
return openoffice, xvfb
return xvfb
return openoffice
def stopFakeEnvironment(stop_openoffice=True):
"""Stop Openoffice and Xvfb """
"""Stop Openoffice """
if stop_openoffice:
openoffice.stop()
xvfb.stop()
return True
......@@ -140,8 +123,6 @@ class CloudoooTestCase(unittest.TestCase):
self.tmp_url = path.join(self.working_path, "tmp")
check_folder(self.working_path, self.tmp_url)
self.uno_path = config.get("app:main", "uno_path")
self.virtual_display_id = config.get("app:main", "virtual_display_id")
self.virtual_display_port_int = config.get("app:main", "virtual_display_port")
self.afterSetUp()
def afterSetUp(self):
......
......@@ -66,7 +66,6 @@ def run():
DAEMON = getattr(module, 'DAEMON', False)
OPENOFFICE = getattr(module, 'OPENOFFICE', False)
XVFB = getattr(module, 'XVFB', False)
TestRunner = unittest.TextTestRunner
suite = unittest.TestSuite()
......@@ -89,19 +88,11 @@ def run():
process.wait()
elif OPENOFFICE:
chdir(ENVIRONMENT_PATH)
openoffice, xvfb = startFakeEnvironment(conf_path=server_cloudooo_conf)
openoffice = startFakeEnvironment(conf_path=server_cloudooo_conf)
try:
TestRunner(verbosity=2).run(suite)
finally:
stopFakeEnvironment()
elif XVFB:
chdir(ENVIRONMENT_PATH)
startFakeEnvironment(start_openoffice=False,
conf_path=server_cloudooo_conf)
try:
TestRunner(verbosity=2).run(suite)
finally:
stopFakeEnvironment(stop_openoffice=False)
else:
chdir(ENVIRONMENT_PATH)
TestRunner(verbosity=2).run(suite)
......
......@@ -33,7 +33,6 @@ from cloudooo.handler.ooo.application.openoffice import OpenOffice
from cloudooo.manager import Manager
from cloudooo.handler.ooo.mimemapper import MimeMapper
from cloudooo.handler.ooo.filter import Filter
from cloudooo.handler.ooo.application.xvfb import Xvfb
from cloudooo.handler.ooo.monitor.request import MonitorRequest
from cloudooo.handler.ooo.granulator import OOGranulator
from cloudooo.interfaces.document import IDocument, IOdfDocument
......@@ -159,7 +158,6 @@ class TestInterface(unittest.TestCase):
def testIApplication(self):
"""Test if OpenOffice implements IApplication"""
self.assertTrue(IApplication.implementedBy(OpenOffice))
self.assertTrue(IApplication.implementedBy(Xvfb))
application_method_list = ["start", "stop", "pid",
"status", "restart",
"loadSettings", "getAddress"]
......
##############################################################################
#
# Copyright (c) 2009-2010 Nexedi SA and Contributors. All Rights Reserved.
# Gabriel M. Monnerat <gabriel@tiolive.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from cloudoooTestCase import CloudoooTestCase, make_suite
from cloudooo.handler.ooo.application.xvfb import Xvfb
class TestXvfb(CloudoooTestCase):
def afterSetUp(self):
"""Instanciate a xvfb object"""
self.xvfb = Xvfb()
self.xvfb.loadSettings(self.hostname,
int(self.virtual_display_port_int),
self.working_path,
self.virtual_display_id,
virtual_screen='1')
def testPid(self):
"""Test pid function to validate if the return is correctly"""
self.assertEquals(self.xvfb.pid(), None)
self.xvfb.start()
self.assertNotEquals(self.xvfb.pid(), None)
self.assertTrue(self.xvfb.status())
self.xvfb.stop()
self.assertEquals(self.xvfb.pid(), None)
self.assertEquals(self.xvfb.status(), False)
def testStatus(self):
"""Test if xvfb is started and stopped correctly"""
self.assertFalse(self.xvfb.status())
try:
self.xvfb.start()
self.assertTrue(self.xvfb.status())
finally:
self.xvfb.stop()
self.assertFalse(self.xvfb.status())
def test_suite():
return make_suite(TestXvfb)
......@@ -33,7 +33,6 @@ import os
import cloudooo.handler.ooo.monitor as monitor
from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.handler.ooo.application.xvfb import xvfb
from cloudooo.wsgixmlrpcapplication import WSGIXMLRPCApplication
from cloudooo.utils.utils import convertStringToBool, configureLogger
from cloudooo.handler.ooo.mimemapper import mimemapper
......@@ -41,8 +40,6 @@ from cloudooo.handler.ooo.mimemapper import mimemapper
def stopProcesses(signum, frame):
monitor.stop()
openoffice.stop()
xvfb.stop()
def application(global_config, **local_config):
"""Method to load all configuration of cloudooo and start the application.
......@@ -52,16 +49,11 @@ def application(global_config, **local_config):
e.g debug_mode=logging.DEBUG
working_path -- Full path to create the environment of the processes.
e.g working_path='/var/run/cloudooo'
virtual_display_port -- Port to start the Xvfb.
virtual_display_id -- Sets the display.
e.g virtual_display_id='99'
application_hostname -- Sets the host to Xvfb and Openoffice.
virtual_screen -- Use to define the screen to Xvfb
e.g virtual_screen='0'
office_binary_path -- Full Path of the OOo executable.
e.g office_binary_path='/opt/openoffice.org3/program'
uno_path -- Full path to pyuno library.
e.g uno_path='/opt/openoffice.org/program'
application_hostname -- Sets the host to Openoffice.
office_binary_path -- Folder where soffice.bin is installed.
e.g office_binary_path='/opt/libreoffice/program'
uno_path -- Folder where UNO library is installed.
e.g uno_path='/opt/libreoffice/basis-link/program/'
"""
prefix = 'env-'
environment_dict = {}
......@@ -87,23 +79,13 @@ def application(global_config, **local_config):
cloudooo_path_tmp_dir = path.join(working_path, 'tmp')
if not path.exists(cloudooo_path_tmp_dir):
mkdir(cloudooo_path_tmp_dir)
# The Xvfb will run in the same local of the OpenOffice
application_hostname = local_config.get('application_hostname')
openoffice_port = int(local_config.get('openoffice_port'))
# Before start Xvfb, first loads the configuration
xvfb.loadSettings(application_hostname,
int(local_config.get('virtual_display_port')),
working_path,
local_config.get('virtual_display_id'),
virtual_screen=local_config.get('virtual_screen'),
start_timeout=local_config.get('start_timeout'))
xvfb.start()
# Loading Configuration to start OOo Instance and control it
openoffice.loadSettings(application_hostname,
openoffice_port,
working_path,
local_config.get('virtual_display_id'),
local_config.get('office_binary_path'),
local_config.get('uno_path'),
local_config.get('openoffice_user_interface_language',
......
......@@ -8,10 +8,10 @@ debug_mode = True
# are stored. In this folder is necessary create a folder tmp, because this
# folder is used to create all temporary documents.
working_path = /hd/cloudooo/run
# Folder where OpenOffice Uno interpreter is installed
uno_path = /opt/openoffice.org3/basis-link/program
# Folder where OpenOffice Binarie is installed
office_binary_path = /opt/openoffice.org3/program
# Folder where UNO library is installed
uno_path = /opt/libreoffice/basis-link/program
# Folder where soffice.bin is installed
office_binary_path = /opt/libreoffice/program
#
## Monitor Settings
#
......@@ -33,14 +33,6 @@ application_hostname = localhost
# OpenOffice Port
openoffice_port = 4062
#
## Xvfb Settings
#
# Default port to xvfb
virtual_display_port = 6097
# ID of the virtual display where OOo instances are launched
virtual_display_id = 97
virtual_screen = 0
#
## Environment Variable Settings (env-KEY = value)
#
# specify preferrable library locations
......
......@@ -11,9 +11,6 @@ enable_memory_monitor = @ENABLE_MEMORY_MONITOR@
limit_memory_used = @MAXIMUM_USE_BY_OPENOFFICE@
application_hostname = @APPLICATION_HOSTNAME@
openoffice_port = @OPENOFFICE_PORT@
virtual_display_port = @XVFB_PORT@
virtual_display_id = @XVFB_DISPLAY_ID@
virtual_screen = @XVFB_SCREEN_NUMBER@
[server:main]
use = egg:PasteScript#wsgiutils
......
......@@ -8,10 +8,10 @@ debug_mode = True
# are stored. In this folder is necessary create a folder tmp, because this
# folder is used to create all temporary documents.
working_path = /hd/cloudooo/run
# Folder where OpenOffice Uno interpreter is installed
uno_path = /opt/openoffice.org3/basis-link/program
# Folder where OpenOffice Binarie is installed
office_binary_path = /opt/openoffice.org3/program
# Folder where UNO library is installed
uno_path = /opt/libreoffice/basis-link/program
# Folder where soffice.bin is installed
office_binary_path = /opt/libreoffice/program
#
## Monitor Settings
#
......@@ -33,13 +33,13 @@ application_hostname = localhost
# OpenOffice Port
openoffice_port = 4062
#
## Xvfb Settings
## Environment Variable Settings (env-KEY = value)
#
# Default port to xvfb
virtual_display_port = 6097
# ID of the virtual display where OOo instances are launched
virtual_display_id = 97
virtual_screen = 0
# specify preferrable library locations
# env-LD_LIBRARY_PATH = /opt/erp5/trunk/parts/fontconfig/lib:/opt/erp5/trunk/parts/libpng/lib:/opt/erp5/trunk/parts/zlib/lib
#
# specify preferrable executable locations
# env-PATH = /opt/erp5/trunk/parts/imagemagick/bin:/opt/erp5/trunk/parts/w3m/bin
[server:main]
use = egg:PasteScript#wsgiutils
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment