Commit 75e077d0 authored by Łukasz Nowak's avatar Łukasz Nowak

- use dedicated recipe to install oood instance (erp5.recipe.ooodinstance)

 - as templates are inside this recipe remove them
 - rearrange configuration of oood instance to make it maintainable and readable


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36550 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4b7ab639
[buildout] [buildout]
parts = oood-instance parts = oood-instance
[configuration] [oood-instance]
openoffice_python = ${software_definition:openoffice_software}/program/python depends =
openoffice_program = ${software_definition:openoffice_software}/program ${oood-directories:command}
openoffice_uno = ${software_definition:openoffice_software}/basis-link/program/ recipe = erp5.recipe.ooodinstance
wrapper_path = ${buildout:data-bin-directory}/oood-runserw
oood_conf_file = ${buildout:etc-directory}/oood.conf oood_conf_file = ${buildout:etc-directory}/oood.conf
oood_log_file = ${buildout:log-directory}/oood.log
wrapper_part = oood-wrapper
configuration_part = oood-configuration
[oood-wrapper]
openoffice_python = ${software_definition:openoffice_software}/program/python
oood_pid = ${oood-configuration:oood_run}/server_pid.lock
openoffice_uno = ${oood-configuration:openoffice_uno}
oood_software = ${oood-configuration:oood_software}
[oood-configuration]
oood_software = ${software_definition:oood_software}
oood_run = ${buildout:var-directory}/oood oood_run = ${buildout:var-directory}/oood
oood_pid = ${:oood_run}/server_pid.lock
oood_tmp = ${:oood_run} oood_tmp = ${:oood_run}
oood_host = 127.0.0.1 oood_host = 127.0.0.1
oood_port = 8008 oood_port = ${configuration:oood_port}
oood_pool_host = localhost oood_pool_host = localhost
oood_pool_range_start = 4060 oood_pool_range_start = 4060
oood_instance_load_time = 20 oood_instance_load_time = 20
oood_instance_timeout = 360 oood_instance_timeout = 360
oood_virtual_display_id = 99 oood_virtual_display_id = 99
openoffice_uno = ${software_definition:openoffice_software}/basis-link/program/
openoffice_program = ${software_definition:openoffice_software}/program
oood_log_file = ${buildout:log-directory}/oood.log
[configuration]
oood_port = 8008
[oood-directories] [oood-directories]
recipe = plone.recipe.command recipe = plone.recipe.command
command = mkdir -p ${configuration:oood_run} depends = ${create-directories:command}
command = mkdir -p ${oood-configuration:oood_run}
update-command = ${:command} update-command = ${:command}
[oood-etc]
recipe = collective.recipe.template
input = ${software_definition:software_home}/templates/oood.conf.in
output = ${configuration:oood_conf_file}
[oood-instance]
depends =
${oood-etc:output}
${oood-directories:command}
recipe = collective.recipe.template
input = ${software_definition:software_home}/templates/oood-runserw.in
output = ${buildout:data-bin-directory}/oood-runserw
[conversion-server-template] [conversion-server-template]
<= oood-instance <= oood-instance
[requirements]
binary = Xvfb
#!${configuration:openoffice_python}
import signal
import time
import subprocess
import sys
import os
PID_FILE = "${configuration:oood_pid}"
OOOD_COMMAND = " PYTHONPATH=${configuration:openoffice_uno} " + \
" ${configuration:openoffice_python} " + \
" ${software_definition:oood_software}/runserw.py "
FLUSH_COMMAND = " PYTHONPATH=${configuration:openoffice_uno} " + \
" ${configuration:openoffice_python} " + \
" ${software_definition:oood_software}/start.py " + \
" --flush > /dev/null 2>&1 /dev/null"
INSTANCE_PID_FILE = "/".join(PID_FILE.split("/")[:-1] + ["instance_0.pid"])
class Oood:
pid = None
openoffice_pid = None
def __init__(self):
self.setsignals()
def run(self):
subprocess.call(OOOD_COMMAND + "--start > /dev/null 2>&1 /dev/null &",
shell=True)
subprocess.call(FLUSH_COMMAND, shell=True)
while 1:
# Load the soffice pid for make sure it will be killed
# when this wrapper is killed.
# The oood does a real mess with the open office pid file and we cannot
# trust always into the pid file. So if the process still running, don't
# upload the openoffice_pid.
update_pid_required = True
if self.openoffice_pid is not None:
try:
os.kill(self.openoffice_pid, 0)
update_pid_required = False
except OSError:
# Process is running ignore.
pass
if os.path.exists(INSTANCE_PID_FILE) and update_pid_required:
self.openoffice_pid = int(open(INSTANCE_PID_FILE, "r").read())
# Update the file, if it is not removed by oood by mistake.
if os.path.exists(PID_FILE):
self.pid = int(open(PID_FILE, "r").read())
time.sleep(40)
time.sleep(5)
def setsignals(self):
signal.signal(signal.SIGTERM, self.stop)
signal.signal(signal.SIGHUP, self.stop)
signal.signal(signal.SIGINT, self.stop)
signal.signal(signal.SIGUSR1, self.stop)
signal.signal(signal.SIGUSR2, self.stop)
def stop(self, sig, frame):
if os.path.exists(PID_FILE):
self.pid = int(open(PID_FILE, "r").read())
else:
print "Pid File does not exist!"
# Stop command in an appropriate way.
subprocess.call(OOOD_COMMAND + "--stop > /dev/null 2>&1 /dev/null ",
shell=True)
# Call Flush Command to stop openoffices.
subprocess.call(FLUSH_COMMAND, shell=True)
if self.pid is not None:
try:
# If oood process still running be brutal and force it stop.
os.kill(self.pid, 9)
print "Kill runserw pid (%s)" % self.pid
except OSError:
pass # OOOD is already stopped, nothing to do.
if self.openoffice_pid is not None:
try:
# Use SIGTERM is required for this case, because openoffice use
# a shell script to run and "trap" to kill the childrens.
os.kill(self.openoffice_pid , 15)
print "Kill openoffice pid (%s)" % self.pid
except OSError:
pass # OpenOffice is already stopped, nothing to do.
sys.exit(0)
def main():
pp = Oood()
pp.run()
if __name__ == '__main__':
main()
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
#
# 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 advised 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.
#
##############################################################################
###################################################################
# System config
###################################################################
[System]
# Folder where all oood core files are installed
oood_home = ${software_definition:oood_software}
# Folder where pid files, lock files and virtual frame buffer mappings are
# stored
run_dir = ${configuration:oood_run}
tmp_dir = ${configuration:oood_tmp}
# Folder where OpenOffice Uno interpreter is installed
uno_path = ${configuration:openoffice_uno}
# Folder where soffice is installed (default: uno_path)
prog_dir = ${configuration:openoffice_program}
# Complete absolute path to the log file
log_file = ${configuration:oood_log_file}
# debug_mode tells oood to leave files in tmp directory
debug_mode = False
log_level = logging.DEBUG
###################################################################
# Server settings
###################################################################
[Server]
server_host = ${configuration:oood_host}
# Other http-alt ports are 591 and 8080
server_port = ${configuration:oood_port}
# name of local printer to print files directly
printer_name = default_printer
###################################################################
# Pool settings
###################################################################
[Pool]
# The pool consist of several OpenOffice.org instances
pool_host = ${configuration:oood_pool_host}
# According www.iana.org/assignments/port-numbers , 4060-4088 port range is
# unassigned
pool_port_range_start = ${configuration:oood_pool_range_start}
# time in seconds we have to give one OOo instance to load in restart
instance_load_time = ${configuration:oood_instance_load_time}
# seconds to wait before killing and restarting OOo instance
instance_timeout = ${configuration:oood_instance_timeout}
# ID of the virtual display where OOo instances are launched
virtual_display_id = ${configuration:oood_virtual_display_id}
###################################################################
# Formats
###################################################################
# Here you can configure which file formats should be included on the
# "target format item list" and which should be skipped
# by either specifying formats to use, or formats to skip
# default is using all formats defined in mimemapper
# Format list should be given as comma-separated list of extensions
# (as defined in mimemapper)
# example:
# [Text]
# use_formats = odt, doc, rtf, html-writer, pdf
# [Spreadsheet]
# skip_formats = slk, pxl, 3_0.sdc.vor
# XXX for now, if you use this option, you MUST include ODF format in
# your "use" list, otherwise oood will return an empty list. This is a
# bug and will be fixed.
[Text]
#use_formats = All
#skip_formats = None
[Spreadsheet]
#use_formats = All
#skip_formats = None
[Presentation]
#use_formats = All
#skip_formats = None
[Drawing]
#use_formats = All
#skip_formats = None
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