From 824d0d1afed88ac0eac965144288899dd5db578c Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 22 Aug 2005 15:19:11 +0000 Subject: [PATCH] moved router, gateways to a single config file opensrf_core.xml 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 --- bin/opensrf_all | 3 +- examples/opensrf_core.xml.example | 89 ++++++++++++++++++++++++++++++++++++ src/Makefile | 1 + src/gateway/Makefile | 1 - src/gateway/gateway.xml.example | 30 ------------ src/gateway/mod_ils_gateway.c | 6 ++- src/libstack/osrf_app_session.c | 4 +- src/libstack/osrf_system.c | 25 +++++----- src/libstack/osrf_system.h | 10 +++- src/router/Makefile | 1 - src/router/router.c | 10 ++-- src/router/router_config.xml.example | 52 --------------------- src/srfsh/srfsh.c | 2 +- 13 files changed, 125 insertions(+), 109 deletions(-) create mode 100644 examples/opensrf_core.xml.example delete mode 100644 src/gateway/gateway.xml.example delete mode 100644 src/router/router_config.xml.example diff --git a/bin/opensrf_all b/bin/opensrf_all index 510fd0e..9014411 100755 --- a/bin/opensrf_all +++ b/bin/opensrf_all @@ -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 index 0000000..a29f5f1 --- /dev/null +++ b/examples/opensrf_core.xml.example @@ -0,0 +1,89 @@ + + + + + + + + + + router + + + + 127.0.0.1 + + + + mylogin + mypassword + + + 5222 + /openils/var/sock/jserver.sock + + + /openils/var/log/gateway.log + + 3 + + + + + router + + 127.0.0.1 + + mylogin + mypassword + 5222 + /openils/var/sock/jserver.sock + /openils/var/log/gateway.log + 3 + + + + + + + 0 + + + + 127.0.0.1 + + 127.0.0.1 + + + + + 127.0.0.1 + + 5222 + /openils/var/sock/unix_sock + + + router + mypassword + + router + 10 + 5 + + + /openils/var/log/router.log + 3 + + + + + + + + + + diff --git a/src/Makefile b/src/Makefile index 25c7904..7c65d73 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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) # -------------------------------------------------------------------------------- diff --git a/src/gateway/Makefile b/src/gateway/Makefile index dfabd9e..38e898e 100644 --- a/src/gateway/Makefile +++ b/src/gateway/Makefile @@ -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 index ed8cdd2..0000000 --- a/src/gateway/gateway.xml.example +++ /dev/null @@ -1,30 +0,0 @@ - - - - - INFO - - - router - - - - host.example.com - - - - my_jabber_login - my_jabber_password - 5222 - /path/to/unix_sock_file - - - - - - /path/to/log/gateway.log - - - diff --git a/src/gateway/mod_ils_gateway.c b/src/gateway/mod_ils_gateway.c index e8dd01b..9fafbd2 100644 --- a/src/gateway/mod_ils_gateway.c +++ b/src/gateway/mod_ils_gateway.c @@ -24,7 +24,11 @@ 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); diff --git a/src/libstack/osrf_app_session.c b/src/libstack/osrf_app_session.c index f9dee7a..3648e40 100644 --- a/src/libstack/osrf_app_session.c +++ b/src/libstack/osrf_app_session.c @@ -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); diff --git a/src/libstack/osrf_system.c b/src/libstack/osrf_system.c index def7433..8c8ced8 100644 --- a/src/libstack/osrf_system.c +++ b/src/libstack/osrf_system.c @@ -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); diff --git a/src/libstack/osrf_system.h b/src/libstack/osrf_system.h index 5f42728..70fe6f3 100644 --- a/src/libstack/osrf_system.h +++ b/src/libstack/osrf_system.h @@ -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 diff --git a/src/router/Makefile b/src/router/Makefile index fc7c4ee..cd1e3ec 100644 --- a/src/router/Makefile +++ b/src/router/Makefile @@ -13,7 +13,6 @@ msg: install: echo installing router cp router $(BINDIR) - cp router_config.xml.example $(ETCDIR) router: router.c $(LIB_SOURCES) echo $@ diff --git a/src/router/router.c b/src/router/router.c index f3ddfba..5ca2c19 100644 --- a/src/router/router.c +++ b/src/router/router.c @@ -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 index 1020ddd..0000000 --- a/src/router/router_config.xml.example +++ /dev/null @@ -1,52 +0,0 @@ - - - 0 - - - - - server1.domain.com - server2.domain.com - - - client1.domain.com - client2.domain.com - - - - - - - - jabber_server.domain.com - 5222 - /path/to/unix_sock - router - my_password - router - 10 - 5 - - - - - /pines/log/router.log - - - 3 - - - - diff --git a/src/srfsh/srfsh.c b/src/srfsh/srfsh.c index 8672c2d..d1cdf01 100644 --- a/src/srfsh/srfsh.c +++ b/src/srfsh/srfsh.c @@ -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 { -- 2.11.0