[Libreoffice-commits] online.git: loolwsd/LOOLWSD.cpp loolwsd/LOOLWSD.hpp loolwsd/loolwsd.xml

Ashod Nakashian ashod.nakashian at collabora.co.uk
Thu Apr 7 04:44:53 UTC 2016


 loolwsd/LOOLWSD.cpp |   38 +++++++++++++++++++++++++++++++++++++-
 loolwsd/LOOLWSD.hpp |    9 ++++++++-
 loolwsd/loolwsd.xml |    9 +++++----
 3 files changed, 50 insertions(+), 6 deletions(-)

New commits:
commit 00940d5a0bffb0c2a0224ed16a052f6989ac4062
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Wed Apr 6 23:51:58 2016 -0400

    loolwsd: configure wsd using the config file
    
    Most all configuration values can now be defined
    in the configuration XML. The command-line arguments
    can be used to override some of these values (for
    the convenience of developement and testing) and,
    in a few cases, as a security measure to avoid
    storing sensitive data in the configuration file.
    
    Change-Id: I040b807b1a59a3537bb94646150d3c7d711f8b62
    Reviewed-on: https://gerrit.libreoffice.org/23880
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 91bbf4d..46860d0 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -965,7 +965,7 @@ std::string LOOLWSD::LoSubPath = "lo";
 std::string LOOLWSD::FileServerRoot;
 std::string LOOLWSD::AdminCreds;
 
-int LOOLWSD::NumPreSpawnedChildren = 10;
+unsigned int LOOLWSD::NumPreSpawnedChildren = 0;
 bool LOOLWSD::DoTest = false;
 
 LOOLWSD::LOOLWSD()
@@ -997,6 +997,42 @@ void LOOLWSD::initialize(Application& self)
         }
     }
 
+    if (Cache.empty())
+    {
+        Cache = getPathFromConfig("tile_cache_path");
+    }
+
+    if (SysTemplate.empty())
+    {
+        SysTemplate = getPathFromConfig("sys_template_path");
+    }
+
+    if (LoTemplate.empty())
+    {
+        LoTemplate = getPathFromConfig("lo_template_path");
+    }
+
+    if (ChildRoot.empty())
+    {
+        ChildRoot = getPathFromConfig("child_root_path");
+    }
+
+    if (LoSubPath.empty())
+    {
+        LoSubPath = getPathFromConfig("lo_jail_subpath");
+    }
+
+    if (FileServerRoot.empty())
+    {
+        FileServerRoot = getPathFromConfig("file_server_root_path");
+    }
+
+    if (NumPreSpawnedChildren == 0)
+    {
+        // Default to 10 children.
+        NumPreSpawnedChildren = config().getUInt("num_prespawn_children", 10);
+    }
+
     ServerApplication::initialize(self);
 }
 
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index 76e5246..ea87f50 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -36,7 +36,7 @@ public:
     // An Application is a singleton anyway,
     // so just keep these as statics.
     static std::atomic<unsigned> NextSessionId;
-    static int NumPreSpawnedChildren;
+    static unsigned int NumPreSpawnedChildren;
     static int BrokerWritePipe;
     static bool DoTest;
     static std::string Cache;
@@ -73,6 +73,13 @@ private:
     std::string getPathFromConfig(const std::string& property) const
     {
         auto path = config().getString(property);
+        if (path.empty() && config().hasProperty(property + "[@default]"))
+        {
+            // Use the default value if empty and a default provided.
+            path = config().getString(property + "[@default]");
+        }
+
+        // Reconstruct absolute path if relative.
         if (config().hasProperty(property + "[@relative]") &&
             config().getBool(property + "[@relative]"))
         {
diff --git a/loolwsd/loolwsd.xml b/loolwsd/loolwsd.xml
index 96d7202..7d356b1 100644
--- a/loolwsd/loolwsd.xml
+++ b/loolwsd/loolwsd.xml
@@ -1,12 +1,13 @@
 <config>
 
-    <num_prespawn_kit desc="Number of child processes to keep started in advance and waiting for new clients." type="uint">1</num_prespawn_kit>
-    <sys_template_path desc="Path to a template tree with shared libraries etc to be used as source for chroot jails for child processes." type="path" relative="false"></sys_template_path>
+    <tile_cache_path desc="Path to a directory where to keep the persistent tile cache." type="path" relative="false" default="/usr/local/var/cache/loolwsd"></tile_cache_path>
+    <sys_template_path desc="Path to a template tree with shared libraries etc to be used as source for chroot jails for child processes." type="path" relative="true" default="systemplate"></sys_template_path>
     <lo_template_path desc="Path to a LibreOffice installation tree to be copied (linked) into the jails for child processes. Should be on the same file system as systemplate." type="path" relative="false"></lo_template_path>
-    <child_root_path desc="Path to the directory under which the chroot jails for the child processes will be created. Should be on the same file system as systemplate and lotemplate." type="path" relative="false"></child_root_path>
+    <child_root_path desc="Path to the directory under which the chroot jails for the child processes will be created. Should be on the same file system as systemplate and lotemplate. Must be an empty directory." type="path" relative="true" default="jails"></child_root_path>
     <lo_jail_subpath desc="Relative path where the LibreOffice installation will be copied inside a jail." type="path" relative="true" default="lo">lo</lo_jail_subpath>
-    <file_server_root_path desc="Path to the directory that should be considered root for the file server." type="path" relative="true" default="../loleaflet/">../loleaflet/</file_server_root_path>
+    <file_server_root_path desc="Path to the directory that should be considered root for the file server. This should be the directory containing loleaflet." type="path" relative="true" default="../loleaflet/../"></file_server_root_path>
 
+    <num_prespawn_children desc="Number of child processes to keep started in advance and waiting for new clients." type="uint" default="10">1</num_prespawn_children>
     <logging>
         <color type="bool">true</color>
         <level type="string">trace</level>


More information about the Libreoffice-commits mailing list