[Erp5-report] r24534 - in /erp5/trunk/utils/oood: config.py oood.conf runserw.py start.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Nov 10 09:16:54 CET 2008
Author: kazuhiko
Date: Mon Nov 10 09:16:52 2008
New Revision: 24534
URL: http://svn.erp5.org?rev=24534&view=rev
Log:
Sorry, I revert r.24504 (Xvfb is no longer required for OOo 2.3 or later.).
OOo (even 3.0) has a bug with '-headless' mode in converting to image
format like PNG, that only a part of the full image can be made.
And '-invisible' mode without Xvfb seems to act just same as '-headless'
mode, and makes bogus image outputs.
Modified:
erp5/trunk/utils/oood/config.py
erp5/trunk/utils/oood/oood.conf
erp5/trunk/utils/oood/runserw.py
erp5/trunk/utils/oood/start.py
Modified: erp5/trunk/utils/oood/config.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/config.py?rev=24534&r1=24533&r2=24534&view=diff
==============================================================================
--- erp5/trunk/utils/oood/config.py [utf8] (original)
+++ erp5/trunk/utils/oood/config.py [utf8] Mon Nov 10 09:16:52 2008
@@ -86,6 +86,7 @@
pool_port_range_start = config.getint('Pool', 'pool_port_range_start')
instance_load_time = config.getint('Pool', 'instance_load_time')
instance_timeout = config.getint('Pool', 'instance_timeout')
+virtual_display_id = config.getint('Pool', 'virtual_display_id')
pool_size = 1 # do not change this
Modified: erp5/trunk/utils/oood/oood.conf
URL: http://svn.erp5.org/erp5/trunk/utils/oood/oood.conf?rev=24534&r1=24533&r2=24534&view=diff
==============================================================================
--- erp5/trunk/utils/oood/oood.conf [utf8] (original)
+++ erp5/trunk/utils/oood/oood.conf [utf8] Mon Nov 10 09:16:52 2008
@@ -72,6 +72,8 @@
instance_load_time = 20
# seconds to wait before killing and restarting OOo instance
instance_timeout = 360
+# ID of the virtual display where OOo instances are launched
+virtual_display_id = 99
###################################################################
# Formats
Modified: erp5/trunk/utils/oood/runserw.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/runserw.py?rev=24534&r1=24533&r2=24534&view=diff
==============================================================================
--- erp5/trunk/utils/oood/runserw.py [utf8] (original)
+++ erp5/trunk/utils/oood/runserw.py [utf8] Mon Nov 10 09:16:52 2008
@@ -285,6 +285,8 @@
Log.info(message)
print message
sys.exit(1)
+ import start as starter
+ starter.startVirtualFrameBuffer()
from dispatcher import Dispatcher, MySerw
if debug:
Modified: erp5/trunk/utils/oood/start.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/start.py?rev=24534&r1=24533&r2=24534&view=diff
==============================================================================
--- erp5/trunk/utils/oood/start.py [utf8] (original)
+++ erp5/trunk/utils/oood/start.py [utf8] Mon Nov 10 09:16:52 2008
@@ -92,6 +92,8 @@
open('%s/Common.xcu' % common_xcu_dir, 'w').write(
open('%s/Common.xcu' % os.path.dirname(__file__)).read())
+ # "'-display :%d' % config.virtual_display_id" argument is not working, that's why we use
+ # environnment variable. See "man xhost" for more details.
new_context = os.environ
if on_top:
args_and_env = [ BIN # First arg is always the name of the binary software we execute
@@ -100,7 +102,7 @@
, new_context
]
else:
- new_context['DISPLAY'] = ''
+ new_context['DISPLAY'] = ':%s' % config.virtual_display_id
args_and_env = [ BIN # First arg is always the name of the binary software we execute
, '-invisible'
, '-nologo'
@@ -212,6 +214,53 @@
Log.info("Pool - Flushed: all instances killed")
+def startVirtualFrameBuffer():
+ """
+ This method start a virtual frame buffer (Xvfb)
+ """
+ VIRTUAL_SCREEN = 0
+ XORG_TMP_PATH = "/tmp/.X11-unix"
+ import pwd
+ oood_uid = os.getuid()
+ oood_gid = os.getgid()
+ # Clean previous virtual display if found
+ killVirtualFrameBuffer()
+ # Remove bad previous socket
+ xorg_socket = os.path.join(XORG_TMP_PATH, 'X%s' % config.virtual_display_id)
+ if os.path.exists(xorg_socket) and \
+ (os.stat(xorg_socket).st_uid != oood_uid or \
+ os.stat(xorg_socket).st_gid != oood_gid):
+ msg = "Pool - Can't start Virtual Frame Buffer because '%s' is not owned by %s" \
+ % (xorg_socket,pwd.getpwuid(os.getuid())[0] )
+ Log.warning(msg)
+ print msg
+ sys.exit(1)
+ # Start the new virtual display server
+ os.system("Xvfb -ac :%s -screen %s 800x600x16 -fbdir %s &" % ( config.virtual_display_id
+ , VIRTUAL_SCREEN
+ , config.run_dir
+ ))
+ Log.info("Pool - Virtual frame buffer started")
+ Log.info("Pool - To see the virtual display, run 'xwud -in %s/Xvfb_screen%s'" % (config.run_dir, VIRTUAL_SCREEN))
+
+
+def killVirtualFrameBuffer():
+ """
+ This method kill the virtual frame buffer (Xvfb)
+ """
+ # Search all Xvfb process running on display ID given in the config file
+ result = getstatusoutput("ps ax | grep 'Xvfb' | grep ':%s'" % config.virtual_display_id)
+ # Search the running process
+ killed = False
+ for process in result[1].splitlines():
+ if process.find('grep') == -1:
+ pid = int(process.strip().split(' ')[0])
+ os.kill(pid, 9)
+ killed = True
+ if killed:
+ Log.info("Pool - Virtual frame buffer killed")
+
+
def showThreadingStatus():
import xmlrpclib
uri = 'http://%s:%d' % (config.server_host, config.server_port)
@@ -296,6 +345,8 @@
sys.exit(0)
elif o in ("-f", "--flush"):
flushPool()
+ if not WIN:
+ killVirtualFrameBuffer()
sys.exit(0)
elif o in ("-s", "--status", "--stat"):
showPoolStatus()
More information about the Erp5-report
mailing list