
Document conversion daemon.


The document conversion daemon is a php script which is bundled with the extension. 
It communicates with OpenOffice.org and does the actual conversion of documents. 
The script needs to be started with the command-line version of PHP, which means 
that you need to execute the following command from the command line:

$ php extension/ezodf/daemon.php


Note: The document conversion daemon will only run under Linux since the socket support in PHP does not work under Windows.
Note: To get the daemon to work you need to have compiled PHP with the following switches:
--enable-cli
--enable-pcntl
--enable-sockets

During the conversion, daemon runs openoffice from command line to do the actual conversion. Unfortunately
openoffice requres X server to connect to, eventhough with -invisible key it does not display anything. So openoffice 
checks if it can connect to some X server. If you do not want to have X server running on your server you can use 
"fake" X server Xvfb ( X virtual frame buffer server ). This server does not open or requre any phisical screen 
devices to run. It just maps screen in the memory. Other possibility is to use X server on another machine, 
this X server has to allow X connections from remote host. So in daemon.php you need to specify DISPLAY openoffice 
binary will try to connect to. On the top of daemon.php you will find variable you need to modify:

$display = ':0'; 

Set the numeber of display you are going to use. For the current running X server it is :0. 
If you start Xvfb server you may specify the display number it will use. 

$ Xvfb :1 &

So after this in daemon.php you set:

$display = ':1'; 

And openoffice will use X server on virtual screen :1 to connect to.


Document conversion daemon can be configured as xinetd service. For this you need coverttooo.php utility which is 
supplied with this ezodf extension. Here is and example of xinetd conf file which needs to be placed 
in /etc/xinetd.d/ directory.
File: /etc/xinetd.d/ezpublishconv
service ezpconvertdaemon
{
        id              = ezpconvertdaemon
        type            = UNLISTED
        socket_type     = stream
        protocol        = tcp
        port            = 9090
        server          = /opt/ezpublish/bin/php
        server_args     = /opt/ezpublish/sites/trunk/extension/ezodf/converttooo.php
        user            = sp
        group = sp
        wait            = no
        disable         = no
}

Where:
  /opt/ezpublish/bin/php - is the full path to your php cli executable
  /opt/ezpublish/sites/trunk/extension/ezodf/converttooo.php - is the full path to your convert script.
  user  = sp
  group = sp - user and usergroup from which covert tool will be started.

Openoffice requires HOME env. variable, for proper configuration please edit converttooo.php and on the 
top of the file modify the:
$homeDir = "/home/sp";
and 
$display = ':1';  
(display here has the same meaning as for daemon.php)
variable. To be sure that openoffice will start from conversion script login to the system with user 
from whom convert daemon will run and then:
$ export DISPLAY=[display you set above]
$ export HOME=[home dir from above]
$ openoffice.org-2.0
If openoffice starts it means that mostprobably you wont have any problems with conversion script.

So now you can restart xinetd and the service should be available.

Configuration of daemon as xinetd service is better, since daemon is started each time conversion is required, 
and if the daemon crashes for some reason it will be started next time from scratch. Also you can do much better security tuning 
with xinetd.($ man xinetd.conf)



