myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [3079] Processes servers list are saved using a `NodeT


From: Giuseppe Scrivano
Subject: [myserver-commit] [3079] Processes servers list are saved using a `NodeTree' structure inside the main configuration file.
Date: Mon, 04 May 2009 18:34:17 +0000

Revision: 3079
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3079
Author:   gscrivano
Date:     2009-05-04 18:34:16 +0000 (Mon, 04 May 2009)
Log Message:
-----------
Processes servers list are saved using a `NodeTree' structure inside the main 
configuration file.

Modified Paths:
--------------
    trunk/myserver/documentation/process_security.texi
    trunk/myserver/src/base/process/process_server_manager.cpp

Modified: trunk/myserver/documentation/process_security.texi
===================================================================
--- trunk/myserver/documentation/process_security.texi  2009-05-04 18:34:12 UTC 
(rev 3078)
+++ trunk/myserver/documentation/process_security.texi  2009-05-04 18:34:16 UTC 
(rev 3079)
@@ -67,25 +67,22 @@
 FastCGI/SCGI configuration inside MIME types by its name.
 
 @example
-<PROCESS_SERVER>
-        <NAME>/opt/bin/fastcgi_server</NAME>
-        <DOMAIN>fastcgi</DOMAIN>
-        <HOST>localhost</HOST>
-        <PORT>2010</PORT>
-        <LOCAL>yes</LOCAL>
-        <UID>1000</UID>
-        <GID>1000</GID>
-</PROCESS_SERVER>
+<!-- Inside myserver.xml.  -->
+<DEFINE name="process_servers.list">
+  <DEFINE server="/opt/bin/fastcgi_server" domain="fastcgi"
+          host="localhost" port="2010" local="yes" uid="1000"
+          gid="1000"/>
+</DEFINE>
 @end example
 
 In the previous example the FastCGI server
 @code{/opt/bin/fastcgi_server} is created.  The @code{domain} must be
 "fastcgi" or "scgi", depending on the specific protocol to use.
address@hidden specifies if the server is handled by myserver or it is
address@hidden specifies if the server is handled by myserver or it is
 already running; in the former case, myserver will simply access and
 use it.
-If the server is not local then the @code{name} is a simple label that
-can be used by a MIME type trought @code{param} to access it.
+If the server is not local then the @code{server} is a simple label
+that can be used by a MIME type trought @code{param} to access it.
 
 It is possible to specify a different uid/gid for the local server
 process and don't maintain the original myserver process privileges.
@@ -96,14 +93,9 @@
 registers it on the @code{fcgi} extension:
 
 @example
-<!-- Inside myserver.xml.  -->
-<PROCESS_SERVER>
-        <NAME>a_remote_server</NAME>
-        <DOMAIN>fastcgi</DOMAIN>
-        <HOST>foo</HOST>
-        <PORT>2010</PORT>
-        <LOCAL>NO</LOCAL>
-</PROCESS_SERVER>
+<DEFINE name="process_servers.list">
+  <DEFINE server="a_remote_server" domain="fastcgi" host="foo" port="2010" 
local="no"/>
+</DEFINE>
 
 <!-- Inside MIMEtypes.xml.  -->
 <MIME mime="text/html" handler="RUNFASTCGI" param="a_remote_server">

Modified: trunk/myserver/src/base/process/process_server_manager.cpp
===================================================================
--- trunk/myserver/src/base/process/process_server_manager.cpp  2009-05-04 
18:34:12 UTC (rev 3078)
+++ trunk/myserver/src/base/process/process_server_manager.cpp  2009-05-04 
18:34:16 UTC (rev 3079)
@@ -42,87 +42,95 @@
 /*!
  *Load the class.
  */
-void ProcessServerManager::load()
+void ProcessServerManager::load ()
 {
-  XmlParser* conf = ::Server::getInstance()->getConfiguration();
-  xmlNodePtr node =  xmlDocGetRootElement(conf->getDoc())->xmlChildrenNode;
-  for(;node; node = node->next)
-  {
-    string domain;
-    string host;
-    string name;
-    string port;
-    string local;
-    bool localBool = true;
-    int uid = 0;
-    int gid = 0;
-    xmlNodePtr node2;
-    if (strcmpi((const char*)node->name, "PROCESS_SERVER"))
-      continue;
-    node2 = node->children;
-    for (;node2; node2 = node2->next)
+ 
+  string key ("process_servers.list");
+  NodeTree<string> *node = ::Server::getInstance()->getNodeTree (key);
+
+  if (node == NULL)
+    return;
+
+  string serverKey ("server");
+  string domainKey ("domain");
+  string hostKey ("host");
+  string portKey ("port");
+  string localKey ("local");
+  string uidKey ("uid");
+  string gidKey ("gid");
+
+  list<NodeTree<string>*> *children = node->getChildren ();
+
+  for(list<NodeTree<string>*>::iterator it = children->begin ();
+      it != children->end ();
+      it++)
     {
-      if (!node2->children || !node2->children->content)
-        continue;
-      
-      if (!strcmpi ((const char*)node2->name, "NAME"))
-        name.assign ((const char*) node2->children->content);
+      string domain;
+      string host;
+      string name;
+      string port;
+      string local;
+      bool localBool = true;
+      int uid = 0;
+      int gid = 0;
 
-      if (!strcmpi ((const char*)node2->name, "HOST"))
-        host.assign ((const char*) node2->children->content);
+      NodeTree<string>* n = *it;
 
-      if (!strcmpi ((const char*)node2->name, "DOMAIN"))
-        domain.assign ((const char*) node2->children->content);
+      if (n->getAttr (serverKey))
+        name.assign (*n->getAttr (serverKey));
 
-      if (!strcmpi ((const char*)node2->name, "PORT"))
-        port.assign ((const char*) node2->children->content);
+      if (n->getAttr (domainKey))
+        domain.assign (*n->getAttr (domainKey));
 
-      if (!strcmpi ((const char*)node2->name, "LOCAL"))
-        local.assign ((const char*) node2->children->content);
+      if (n->getAttr (hostKey))
+        host.assign (*n->getAttr (hostKey));
 
-      if (!strcmpi ((const char*)node2->name, "UID"))
-        uid = atoi ((const char*) node2->children->content);
+      if (n->getAttr (portKey))
+        port.assign (*n->getAttr (portKey));
 
-      if (!strcmpi ((const char*)node2->name, "GID"))
-        gid = atoi ((const char*) node2->children->content);
-    }
-    
-    if (!local.compare("YES") || !local.compare("yes"))
-      localBool = true;
-    else
-      localBool = false;
+      if (n->getAttr (localKey))
+        local.assign (*n->getAttr (localKey));
 
-    if (name.size () && domain.size ())
-    {
-      u_short portN = 0;
+      if (n->getAttr (uidKey))
+        uid = atoi (n->getAttr (uidKey)->c_str ());
 
-      if(port.size ())
-        portN = atoi (port.c_str());
+      if (n->getAttr (gidKey))
+        gid = atoi (n->getAttr (gidKey)->c_str ());
 
-      if (localBool)
-        runAndAddServer (domain.c_str(), name.c_str(), uid, gid, portN);
+      if (!local.compare("YES") || !local.compare("yes"))
+        localBool = true;
       else
-      {
-        if (portN)
-          addRemoteServer (domain.c_str(), name.c_str(), host.c_str(), portN);
-        else
+        localBool = false;
+
+      if (name.size () && domain.size ())
         {
-          ostringstream msg;
-          msg << "Error: incomplete remote PROCESS_SERVER block, " 
-              << domain  << ":" << name << " needs a port";
-          ::Server::getInstance ()->logWriteln(msg.str().c_str(), 
MYSERVER_LOG_MSG_ERROR);
+          u_short portN = 0;
+
+          if(port.size ())
+            portN = atoi (port.c_str());
+
+          if (localBool)
+            runAndAddServer (domain.c_str(), name.c_str(), uid, gid, portN);
+          else
+            {
+              if (portN)
+                addRemoteServer (domain.c_str(), name.c_str(), host.c_str(), 
portN);
+              else
+                {
+                  ostringstream msg;
+                  msg << "Error: incomplete remote PROCESS_SERVER block, "
+                      << domain  << ":" << name << " needs a port";
+                  ::Server::getInstance ()->logWriteln (msg.str ().c_str (), 
MYSERVER_LOG_MSG_ERROR);
+                }
+            }
         }
-      }
-
+      else
+        {
+          const char *msg = "Error: incomplete PROCESS_SERVER block";
+          ::Server::getInstance ()->logWriteln (msg, MYSERVER_LOG_MSG_ERROR);
+        }
     }
-    else
-    {
-      const char *msg = "Error: incomplete PROCESS_SERVER block";
-      ::Server::getInstance ()->logWriteln(msg, MYSERVER_LOG_MSG_ERROR);
-    }
 
-  }
-
 }
 
 /*!





reply via email to

[Prev in Thread] Current Thread [Next in Thread]