libreoffice-online/loolwsd
Henry Castro cfb748edf7 loolwsd: ensure POCO library is installed into systemplate.
In order to avoid "/usr/bin/loolkit: error while loading shared libraries: libPocoNetd.so.30"
2016-01-05 19:11:31 -04:00
..
bundled/include/LibreOfficeKit Revert "loolwsd: update bundled headers" 2015-12-02 16:46:30 +01:00
debian bccu#1371 add libsm6 as dependency to loolwsd 2015-11-25 15:56:46 +01:00
test loolwsd: fix tests to build again 2016-01-05 21:33:13 +01:00
.gitignore loolwsd: remove g++ from loolwsd-sytemplate-setup 2016-01-05 11:36:18 -04:00
AUTHORS Autofooize 2015-03-09 11:19:00 +02:00
Capabilities.hpp loolwsd: dropCapability now works with --enable-debug 2016-01-05 19:30:02 +00:00
ChangeLog Autofooize 2015-03-09 11:19:00 +02:00
ChildProcessSession.cpp loolwsd: document loading/unloading notifications 2016-01-05 01:03:02 +00:00
ChildProcessSession.hpp loolwsd: document loading/unloading notifications 2016-01-05 01:03:02 +00:00
Common.hpp loolwsd: consolidated TerminationFlag 2016-01-03 15:15:46 +00:00
configure.ac loolwsd: remove g++ from loolwsd-sytemplate-setup 2016-01-05 11:36:18 -04:00
Connect.cpp loolwsd: removed dead code 2015-12-28 23:36:55 +00:00
COPYING Autofooize 2015-03-09 11:19:00 +02:00
INSTALL Autofooize 2015-03-09 11:19:00 +02:00
LoadTest.cpp loolwsd: removed dead code 2015-12-28 23:36:55 +00:00
LoadTest.hpp Start on load testing 2015-03-26 17:04:08 +02:00
LOKitClient.cpp loolwsd: dropCapability moved to Capabilities.hpp 2016-01-03 15:17:05 +00:00
LOKitHelper.hpp loolwsd: Refactored ChildProcessSession 2015-12-23 17:03:43 +00:00
LOOLBroker.cpp loolwsd: when no available child sessions, pre spawns more children 2016-01-05 08:51:05 -04:00
LOOLKit.cpp loolwsd: fix page sharing between broker and lokit (aka forking) 2016-01-05 01:14:28 +00:00
loolmap.c loolwsd: fixes to loolmap 2015-12-23 17:23:48 +00:00
LOOLProtocol.cpp Introduce LOLProtocol::getTokenKeyword() and use it 2015-04-27 21:12:20 +03:00
LOOLProtocol.hpp Server getTextSelection implementation 2015-06-24 18:08:15 +03:00
LOOLSession.cpp loolwsd: removed dead code 2015-12-28 23:36:55 +00:00
LOOLSession.hpp loolwsd: stop dispatch child when closed websocket prison 2015-12-28 17:05:01 -04:00
loolstat loolwsd: update loolstat, socket client and ... 2015-08-08 08:09:22 -04:00
loolwsd-systemplate-setup loolwsd: ensure POCO library is installed into systemplate. 2016-01-05 19:11:31 -04:00
LOOLWSD.cpp loolwsd: dropCapability now works with --enable-debug 2016-01-05 19:30:02 +00:00
LOOLWSD.hpp loolwsd: dropCapability now works with --enable-debug 2016-01-05 19:30:02 +00:00
loolwsd.service loolwsd: loolwsd.service KillMode should be control-group 2015-11-09 13:01:24 +01:00
loolwsd.spec.in loolwsd: setcap loolbroker 2016-01-05 14:33:11 +01:00
Makefile.am loolwsd: fix missing loolbroker dependency 2016-01-05 09:10:28 +01:00
MasterProcessSession.cpp loolwsd: childId is now string 2016-01-05 01:12:42 +00:00
MasterProcessSession.hpp loolwsd: childId is now string 2016-01-05 01:12:42 +00:00
MessageQueue.cpp loolwsd: Added remove_if to MessageQueue 2015-12-23 17:09:48 +00:00
MessageQueue.hpp loolwsd: Added remove_if to MessageQueue 2015-12-23 17:09:48 +00:00
NEWS Autofooize 2015-03-09 11:19:00 +02:00
Png.hpp loolwsd: coding style 2015-11-24 09:43:17 +01:00
protocol.txt loolwsd: renderfont command handler 2015-11-30 11:16:53 +02:00
README loolwsd: remove g++ from loolwsd-sytemplate-setup 2016-01-05 11:36:18 -04:00
reference.txt loolwsd: add initial reference.txt to document HTTP POST API 2015-10-20 18:10:40 +02:00
sysconfig.loolwsd Try to make this handled by systemd 2015-06-01 19:53:29 +03:00
TileCache.cpp loolwsd: safely remove files and directories 2015-12-26 03:59:20 +00:00
TileCache.hpp loolwsd: better error handling and resilience 2015-12-26 03:59:05 +00:00
TODO Temporarily bypass modification time things for actual URLs 2015-04-30 21:12:33 +03:00
Util.cpp loolwsd: log the thread name where available 2016-01-03 15:19:12 +00:00
Util.hpp loolwsd: broker handles sigint and wsd removes childroot 2015-12-28 23:39:13 +00:00

LibreOffice On-Line WebSocket server
====================================

Dependencies
------------

LibreOffice On-Line WebSocket server has the following dependencies:

* libpng
* Poco library: http://pocoproject.org/index.html.
* libcap-progs

Poco can be built with ./configure --prefix=/opt/poco && make install, but
distro packages exist too.

On openSUSE, you can use:

    zypper ar http://download.opensuse.org/repositories/devel:/libraries:/c_c++/openSUSE_13.2/devel:libraries:c_c++.repo
    zypper in poco-devel libcap-progs

Building
--------

loolwsd uses autoconf/automake, so build using the usual:

    MASTER=/path/to/built/core.git # configure for your system

    autoreconf
    automake --add-missing
    ./configure --enable-silent-rules --with-lokit-path=${MASTER}/include
    make

where ${MASTER} is the location of the LibreOffice source tree.

Note that the loolwsd program needs the CAP_SYS_CHROOT capability,
thus you will be asked the root password when running make as it
invokes sudo to run /sbin/setcap.

If you have self-built Poco, add the following to ./configure:

    --with-poco-includes=<POCOINST>/include --with-poco-libs=<POCOINST>/lib

where <POCOINST> means the Poco installation location.

If you have the Poco debugging libraries (eg. you have a self-built
Poco), you can add --enable-debug to the configure options for
additional debugging.

For Windows, a proper VS2013 project is needed.

There is still unconditional debugging output etc. This is a work in
progress.

Running
-------

First create the directory used for caching tiles. It is set as
"${localstatedir}/cache/${PACKAGE}" in the configure.ac, so if you did
not pass any switch to the configure script that affects
"localstatedir, it will be /usr/local/var/cache/loolwsd . If you did
pass such a switch, like --prefix, check config.h for the exact value.

If you're using the defaults you'll need to:

sudo mkdir -p /usr/local/var/cache/loolwsd
sudo chown `whoami` /usr/local/var/cache/loolwsd

Now you need to set up a minimal chroot system, and directory for the jails:

    SYSTEMPLATE=`pwd`/systemplate  # or tweak for your system
    ROOTFORJAILS=`pwd`/jails       # or tweak for your system

    rm -Rf ${SYSTEMPLATE} # clean
    ./loolwsd-systemplate-setup ${SYSTEMPLATE} ${MASTER}/instdir # build template
    mkdir -p ${ROOTFORJAILS} # create location for transient jails.

To run loolwsd the way it is supposed to eventually be run "for real", you can
now do:

    ./loolwsd --systemplate=${SYSTEMPLATE} --lotemplate=${MASTER}/instdir --childroot=${ROOTFORJAILS}

and connect loleaflet to that (see loleaflet/README for more info).

Again, ${MASTER} is location of the LibreOffice source tree with a built
LibreOffice.  This is work in progress, and consequently needs the latest
LibreOffice master.

The ${SYSTEMPLATE} is a directory tree set up using the
loolwsd-systemplate-setup script here. (It should not exist before
running the script.) It will contain the runtime environment needed by
the LibreOffice dynamic libraries used through LibreOfficeKit.
Improvements to that script are very likely needed on various distros.

The ${ROOTFORJAILS} directory above is a presumably initially empty
directory under which loolwsd will create chroot jails for editing
each specific document.

As loolwsd uses hardlinks to "copy" the contents of both
${SYSTEMPLATE} and the ${MASTER}/instdir directories into each chroot
jail, ${SYSTEMPLATE} and ${MASTER}/instdir need to be on the same file
system as ${ROOTFORJAILS}.

If you plan to hack on loolwsd, you probably want to familiarize
yourself with loolwsd's --test and --numprespawns switches, and the
'connect' test program.

For interactive testing, you can use the loolwsd --test switch, or you
can use the 'connect' program. Both accept "commands" from the
protocol on standard input. You can either used them tuly
interactively, or edit input lines into a file, or use shell
scripting, etc. For instance:

    (echo load /some/where/foo.odt; echo tile part=0 width=500 height=500 tileposx=0 tileposy=0 tilewidth=10000 tileheight=10000; sleep 10) |
    ./loolwsd --test --systemplate=/home/tml/lo/master/lool-sys-template --lotemplate=/home/tml/lo/master/instdir --childroot=/home/tml/lo/master/lool-child-root

Debugging
---------

When debugging, you want to add --numprespawns=1 to the loolwsd parameters to
limit the amount of concurrently running processes.

When the crash happens too early, you also want to

    export SLEEPFORDEBUGGER=<number of seconds>

so that you have time to attach to the process.

Then run loolwsd, and attach your debugger to the process you are
interested in. Note that as the loolwsd executable file has
capabilities set, you need to run the debugger with super-user
privilege.

Also, note that as the child processes run in a chroot environment,
they see the LibreOffice shared libraries as being in a directory tree
/lo , but your debugger does not. So in order to be able to
effectively debug the LibreOffice code as used through LibreOfficeKit
by a child loolwsd process, you need to symlink the "lo" subdirectory
of a running child loolwsd process's chroot jail as /lo. Something like:

sudo ln -s ~/libreoffice/master/lool-child-roots/1046829984599121011/lo /lo

Use the ps command to find out exactly the path to use.

Protocol description
--------------------

See protocol.txt for a description of the protocol to be used over the
websocket.

Coding style
------------

There is not really any serious rationale why the code ended up being
written in the style it is... but unless you plan to change some style
detail completely and consistenly all over, please keep to the style
of the existing code when editing.

The style is roughly as follows, in rough order of importance:

- As in LO, no hard TABs in source files. Only spaces. Indentation
  step is four columns.

- As in LO, the braces { and } of the block of if, switch, and while
  statements go on separate lines.

- Following Poco conventions, member variables are prefixed with an
  underscore. But I am not opposed to changing this to 'm_' for
  instance.

- Do use C++11. I admit in some places (out of laziness or ignorance)
  I use Poco API even if there probably is an equivalent std::
  API. (Like for threads.) Feel free to change those, if the std:: API
  is not much more verbose or ugly, and you are sure it is equivalent.

- Always prefer the C++ wrapped version of a C library
  API. I.e. include <cstring> instead of <string.h>, use std::memcpy()
  instead of memcpy(), etc.

- Use std:: prefix for all std API, i.e. don't ever do "using
  std;". But it's OK to use "using Poco::Foo;" all over. Maybe that is
  not a good idea?

- Be as portable as possible, i.e. don't intentionally write Unix-only
  code if there is a choice. Obviously some parts of the code
  currently use Unix-only things like chroot() and link() though.

- Member functions use camelCaseWithInitialLowerCase. I don't like
  CamelCaseWithInitialUpperCase.

- No kind of Hungarian prefixes.