moved router, gateways to a single config file opensrf_core.xml
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 22 Aug 2005 15:19:11 +0000 (15:19 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 22 Aug 2005 15:19:11 +0000 (15:19 +0000)
remvoed router_config.xml and gateway.xml config files
make config.sh only ask for prefix, other directories are assumed (and can obviously be changed in install.conf if necessary)

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@493 9efc2488-bf62-4759-914b-345cdb29e865

13 files changed:
bin/opensrf_all
examples/opensrf_core.xml.example [new file with mode: 0644]
src/Makefile
src/gateway/Makefile
src/gateway/gateway.xml.example [deleted file]
src/gateway/mod_ils_gateway.c
src/libstack/osrf_app_session.c
src/libstack/osrf_system.c
src/libstack/osrf_system.h
src/router/Makefile
src/router/router.c
src/router/router_config.xml.example [deleted file]
src/srfsh/srfsh.c

index 510fd0e..9014411 100755 (executable)
@@ -42,7 +42,6 @@ JSERVERLOG="$LOGDIR/jserver.log" # jabber server log
 JSERVERPORT=5222;                                              # jabber server port 
 JSERVERLEVEL=3; # can be 1-4, 4 is the highest
 JSERVERIP="*"; # can be "*" or a specific local IP address
-ROUTERLOG="$LOGDIR/router.log" # jabber router log
 # --------------------------------------------------------------------------
 # --------------------------------------------------------------------------
 
@@ -82,7 +81,7 @@ function startJserver {
 
 
 function startRouter {
-       "$BINDIR/router" "$ETCDIR/router_config.xml" 
+       "$BINDIR/router" "$ETCDIR/opensrf_core.xml" 
 }
 
 function startOpenSRF {
diff --git a/examples/opensrf_core.xml.example b/examples/opensrf_core.xml.example
new file mode 100644 (file)
index 0000000..a29f5f1
--- /dev/null
@@ -0,0 +1,89 @@
+<?xml version='1.0'?>
+
+<!-- Bootstrap config file for the C opensrf_stack library -->
+<config>
+
+       <!-- The section between <gateway>...</gateway> is a standard OpenSRF C stack config file -->
+       <gateway>
+
+               <!--  the routers's name on the network -->
+               <router_name>router</router_name>
+
+               <!-- jabber domains to connect to (domain1, domain2, ...) -->
+               <domains>
+                       <domain1>127.0.0.1</domain1>
+               </domains>
+
+               <!-- jabber login info -->
+               <username>mylogin</username>
+               <passwd>mypassword</passwd>
+
+               <!-- If the port is a positive number,
+                       we will connect via TCP port, if not and unixpath is defined,
+                       we will connect via UNIX domain socket with the given path -->
+               <port>5222</port>
+               <unixpath>/openils/var/sock/jserver.sock</unixpath>
+       
+               <!-- log file location -->
+               <logfile>/openils/var/log/gateway.log</logfile>
+               <!-- 0 None, 1 Error, 2 Warning, 3 Info, 4 debug -->
+               <loglevel>3</loglevel>
+
+       </gateway>
+
+       <rest_gateway>
+               <router_name>router</router_name>
+               <domains>
+                       <domain1>127.0.0.1</domain1>
+               </domains>
+               <username>mylogin</username>
+               <passwd>mypassword</passwd>
+               <port>5222</port>
+               <unixpath>/openils/var/sock/jserver.sock</unixpath>
+               <logfile>/openils/var/log/gateway.log</logfile>
+               <loglevel>3</loglevel>
+       </rest_gateway>
+
+
+       <!-- ======================================================================================== -->
+
+       <router>
+               <component>0</component> <!-- leave disabled for now -->
+       
+               <trusted_domains>
+                       <!-- Trusted servers are allowed to register apps with the router -->
+                       <server1>127.0.0.1</server1>
+                       <!-- Trusted clients are allowed to send packets through the router -->
+                       <client1>127.0.0.1</client1>
+               </trusted_domains>
+       
+               <transport>
+                       <!-- jabber server are we connecting to -->
+                       <server>127.0.0.1</server>
+                       <!-- If the port is a positive number,
+                               we will connect via TCP port, if not and unixpath is defined,
+                               we will connect via UNIX domain socket with the given path -->
+                       <port>5222</port>
+                       <unixpath>/openils/var/sock/unix_sock</unixpath>
+
+                       <!-- router's name on the network -->
+                       <username>router</username>
+                       <password>mypassword</password>
+                       <!-- router's jabber resource --> 
+                       <resource>router</resource>
+                       <connect_timeout>10</connect_timeout>
+                       <max_reconnect_attempts>5</max_reconnect_attempts>
+               </transport>
+       
+               <logfile>/openils/var/log/router.log</logfile>
+               <loglevel>3</loglevel>
+       
+       </router>
+
+       <!-- ======================================================================================== -->
+
+</config>
+
+
+
+
index 25c7904..7c65d73 100644 (file)
@@ -108,6 +108,7 @@ perl-install:       install-prep
        cp ../bin/opensrf_ctl $(BINDIR)
        cp ../bin/opensrf_all $(BINDIR)
        cp ../examples/opensrf.xml.example $(ETCDIR)
+       cp ../examples/opensrf_core.xml.example $(ETCDIR)
 
 
 # --------------------------------------------------------------------------------
index dfabd9e..38e898e 100644 (file)
@@ -18,7 +18,6 @@ msg:
        echo "-> $$(pwd)"       
 
 install: 
-       cp gateway.xml.example $(ETCDIR)
        echo installing ils_gateway
        $(APXS2) -i -a -n ils_gateway libmod_ils_gateway.so
        echo installing ils_rest_gateway
diff --git a/src/gateway/gateway.xml.example b/src/gateway/gateway.xml.example
deleted file mode 100644 (file)
index ed8cdd2..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<!-- Bootstrap config file for the C opensrf_stack library -->
-<config>
-       <bootstrap>
-               <!-- log level (WARN, INFO, DEBUG) -->
-               <debug>INFO</debug>
-
-               <!-- best to leave this untouched if possible -->
-               <router_name>router</router_name>
-
-               <!-- jabber domains to connect to (domain1, domain2, ...) -->
-               <domains>
-                       <domain1>host.example.com</domain1>
-               </domains>
-
-               <!-- jabber connection information. Note that unix socket connectes are
-                               not yet implemented with any of the C libraries so port will 
-                               have to be a port number -->
-               <username>my_jabber_login</username>
-               <passwd>my_jabber_password</passwd>
-               <port>5222</port>
-               <unixpath>/path/to/unix_sock_file</unixpath>
-
-       </bootstrap>
-
-       <!-- log file location -->
-       <logs>
-               <client>/path/to/log/gateway.log</client>
-       </logs>
-
-</config>
index e8dd01b..9fafbd2 100644 (file)
 
 
 static void mod_ils_gateway_child_init(apr_pool_t *p, server_rec *s) {
-       if( ! osrf_system_bootstrap_client( "/openils/conf/gateway.xml") ) 
+       char* context = "gateway";
+       #ifdef RESTGATEWAY
+       context = "rest_gateway";
+       #endif
+       if( ! osrf_system_bootstrap_client( "/home/erickson/sandbox/openils/conf/opensrf_core.xml", context) ) 
                fatal_handler("Unable to load gateway config file...");
        fprintf(stderr, "Bootstrapping %d\n", getpid() );
        fflush(stderr);
index f9dee7a..3648e40 100644 (file)
@@ -247,8 +247,8 @@ osrf_app_session* osrf_app_client_session_init( char* remote_service ) {
 
        char target_buf[512];
        memset(target_buf,0,512);
-       char* domain    = config_value( "opensrf.bootstrap", "//bootstrap/domains/domain1" ); /* just the first for now */
-       char* router_name = config_value( "opensrf.bootstrap", "//bootstrap/router_name" );
+       char* domain    = config_value( "opensrf.bootstrap", "//%s/domains/domain1", osrf_config_context ); /* just the first for now */
+       char* router_name = config_value( "opensrf.bootstrap", "//%s/router_name", osrf_config_context );
        sprintf( target_buf, "%s@%s/%s",  router_name, domain, remote_service );
        free(domain);
        free(router_name);
index def7433..8c8ced8 100644 (file)
@@ -6,35 +6,32 @@ transport_client* osrf_system_get_transport_client() {
        return global_client;
 }
 
-int osrf_system_bootstrap_client( char* config_file ) {
+int osrf_system_bootstrap_client( char* config_file, char* contextnode ) {
 
        if( config_file == NULL )
                fatal_handler("No Config File Specified\n" );
 
        config_reader_init( "opensrf.bootstrap", config_file ); 
+       
+       osrf_config_context = contextnode;
 
-       char* log_file          = config_value( "opensrf.bootstrap", "//logs/client" );
-       char* log_level = config_value( "opensrf.bootstrap", "//bootstrap/debug" );
-       char* domain            = config_value( "opensrf.bootstrap", "//bootstrap/domains/domain1" ); /* just the first for now */
-       char* username          = config_value( "opensrf.bootstrap", "//bootstrap/username" );
-       char* password          = config_value( "opensrf.bootstrap", "//bootstrap/passwd" );
-       char* port                      = config_value( "opensrf.bootstrap", "//bootstrap/port" );
-       char* unixpath          = config_value( "opensrf.bootstrap", "//bootstrap/unixpath" );
+       char* log_file          = config_value( "opensrf.bootstrap", "//%s/logfile", contextnode );
+       char* log_level = config_value( "opensrf.bootstrap", "//%s/loglevel", contextnode );
+       char* domain            = config_value( "opensrf.bootstrap", "//%s/domains/domain1", contextnode ); /* just the first for now */
+       char* username          = config_value( "opensrf.bootstrap", "//%s/username", contextnode );
+       char* password          = config_value( "opensrf.bootstrap", "//%s/passwd", contextnode );
+       char* port                      = config_value( "opensrf.bootstrap", "//%s/port", contextnode );
+       char* unixpath          = config_value( "opensrf.bootstrap", "//%s/unixpath", contextnode );
 
        int llevel = 0;
        int iport = 0;
        if(port) iport = atoi(port);
-
-       if                      (!strcmp(log_level, "ERROR"))   llevel = LOG_ERROR;
-       else if (!strcmp(log_level, "WARN"))    llevel = LOG_WARNING;
-       else if (!strcmp(log_level, "INFO"))    llevel = LOG_INFO;
-       else if (!strcmp(log_level, "DEBUG"))   llevel = LOG_DEBUG;
+       if(log_level) llevel = atoi(log_level);
 
        log_init( llevel, log_file );
 
        info_handler("Bootstrapping system with domain %s, port %d, and unixpath %s", domain, iport, unixpath );
 
-       // XXX config values 
        transport_client* client = client_init( domain, iport, unixpath, 0 );
        char buf[256];
        memset(buf,0,256);
index 5f42728..70fe6f3 100644 (file)
@@ -6,10 +6,16 @@
 #ifndef OSRF_SYSTEM_H
 #define OSRF_SYSTEM_H
 
-/** Connects to jabber.  Returns 1 on success, 0 on failure */
-int osrf_system_bootstrap_client(); 
+/** Connects to jabber.  Returns 1 on success, 0 on failure 
+       contextnode is the location in the config file where we collect config info
+*/
+
+char* osrf_config_context;
+
+int osrf_system_bootstrap_client( char* config_file, char* contextnode );
 transport_client* osrf_system_get_transport_client();
 
 int osrf_system_shutdown(); 
 
+
 #endif
index fc7c4ee..cd1e3ec 100644 (file)
@@ -13,7 +13,6 @@ msg:
 install: 
        echo installing router
        cp router $(BINDIR)
-       cp router_config.xml.example $(ETCDIR)
 
 router:  router.c $(LIB_SOURCES)
        echo $@
index f3ddfba..5ca2c19 100644 (file)
@@ -27,7 +27,7 @@ int main( int argc, char* argv[] ) {
        config_reader_init( "opensrf.router", argv[1] );        
        if( conf_reader == NULL ) fatal_handler( "main(): Config is NULL" ); 
 
-       /* laod the config options */
+       /* load the config options */
        char* server                    = config_value("opensrf.router", "//router/transport/server");
        char* port                              = config_value("opensrf.router", "//router/transport/port");
        char* unixpath                  = config_value("opensrf.router", "//router/transport/unixpath");
@@ -38,10 +38,14 @@ int main( int argc, char* argv[] ) {
        char* max_retries               = config_value("opensrf.router", "//router/transport/max_reconnect_attempts" );
        char* component         = config_value("opensrf.router", "//router/component" );
 
+       fprintf(stderr, "Router connecting with uname %s, server %s, port %s, unixpath %s",
+               username, server, port, unixpath );
+
 
        /* set up the logger */
-       char* level = config_value("opensrf.router","//log/level");
-       char* log_file = config_value("opensrf.router","//log/file");
+       char* level = config_value("opensrf.router","//router/loglevel");
+       char* log_file = config_value("opensrf.router","//router/logfile");
+
        int llevel = atoi(level);
        fprintf(stderr, "Level %d; file %s\n", llevel, log_file );
 
diff --git a/src/router/router_config.xml.example b/src/router/router_config.xml.example
deleted file mode 100644 (file)
index 1020ddd..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-<router>
-
-       <component>0</component> <!-- leave disabled for now -->
-
-       <trusted_domains>
-
-               <!-- 
-                       Trusted servers are allowed to register apps with the router 
-               -->
-               <server1>server1.domain.com</server1>
-               <server2>server2.domain.com</server2>
-
-               <!--
-                       Trusted clients are allowed to send queries to the router
-               -->
-               <client1>client1.domain.com</client1>
-               <client2>client2.domain.com</client2>
-
-       </trusted_domains>
-
-
-       <!-- jabber connection information. Note that unix socket connectes are
-                       not yet implemented with any of the C libraries so port will 
-                       have to be a port number -->
-
-       <transport>
-               <server>jabber_server.domain.com</server>
-               <port>5222</port>
-               <unixpath>/path/to/unix_sock</unixpath>
-               <username>router</username>
-               <password>my_password</password>
-               <resource>router</resource>
-               <connect_timeout>10</connect_timeout>
-               <max_reconnect_attempts>5</max_reconnect_attempts>
-       </transport>
-
-
-       <log>
-               <file>/pines/log/router.log</file>
-
-               <!--    
-                       0 No logging
-                       1 Error logging
-                       2 Warning
-                       3 Info 
-                       4 debug
-               -->
-               <level>3</level>
-       </log>
-
-
-</router>
index 8672c2d..d1cdf01 100644 (file)
@@ -17,7 +17,7 @@ int main( int argc, char* argv[] ) {
        sprintf(fbuf,"%s/.srfsh.xml",home);
 
        if(!access(fbuf, R_OK)) {
-               if( ! osrf_system_bootstrap_client(fbuf) ) 
+               if( ! osrf_system_bootstrap_client(fbuf, "srfsh") ) 
                        fatal_handler( "Unable to bootstrap client for requests");
 
        } else {