From: erickson Date: Tue, 6 Sep 2005 13:57:57 +0000 (+0000) Subject: changed router binary to opensrf_router to prevent opensrf_all from destroying X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=289ad9bd7fd65532ad992de854b08c802b3cf359;p=opensrf%2Fbjwebb.git changed router binary to opensrf_router to prevent opensrf_all from destroying some other process called router - (needs to be pid based eventually...) gave the router a proc title (jsever is next) updated opensrf_all and opensrf_ctl git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@523 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/bin/opensrf_all b/bin/opensrf_all index f84a747..9f19e87 100755 --- a/bin/opensrf_all +++ b/bin/opensrf_all @@ -81,7 +81,7 @@ function startJserver { function startRouter { - "$BINDIR/router" "$ETCDIR/opensrf_core.xml" + "$BINDIR/opensrf_router" "$ETCDIR/opensrf_core.xml" } function startOpenSRF { @@ -125,7 +125,7 @@ function stopMe { sleep 1; echo "Stopping The Router..."; - killall router; + killall opensrf_router; sleep 1; diff --git a/bin/opensrf_ctl b/bin/opensrf_ctl index 5449094..65b7fd5 100755 --- a/bin/opensrf_ctl +++ b/bin/opensrf_ctl @@ -31,18 +31,22 @@ function startSystem { ;; "stop") - PID=$(ps ax | grep "[0-9] System$" | awk '{print $1}'); + PID=$(ps ax | grep -i "opensrf system" | grep -v grep | awk '{print $1}'); + if [ -z "$PID" ]; then echo "OpenSRF System is not running"; exit; + + else + echo "Killing System...$PID"; + kill -s INT $PID; fi - echo "Killing System...$PID"; - kill -s INT $PID; + echo "Done"; ;; "status") - PID=$(ps ax | grep "[0-9] System$" | awk '{print $1}'); + PID=$(ps ax | grep -i "opensrf system" | grep -v grep | awk '{print $1}'); if [ -z "$PID" ]; then echo "OpenSRF System is not running"; exit 0; diff --git a/src/jserver/jserver-c_main.c b/src/jserver/jserver-c_main.c index b9a6289..53a69ad 100644 --- a/src/jserver/jserver-c_main.c +++ b/src/jserver/jserver-c_main.c @@ -82,6 +82,9 @@ int main(int argc, char* argv[]) { signal(SIGINT, &sig_int_handler); signal(SIGTERM, &sig_int_handler); + //init_proc_title( argc, argv ); + //set_proc_title( "opensrf jabber" ); + launch_server(); return 0; } diff --git a/src/libstack/opensrf.c b/src/libstack/opensrf.c index 1d4c656..f3ab1ba 100644 --- a/src/libstack/opensrf.c +++ b/src/libstack/opensrf.c @@ -16,7 +16,7 @@ int main( int argc, char* argv[] ) { char* context = strdup( argv[3] ); init_proc_title( argc, argv ); - set_proc_title( "opensrf system" ); + set_proc_title( "OpenSRF System" ); osrfSystemBootstrap( host, config, context ); diff --git a/src/libstack/osrf_app_session.c b/src/libstack/osrf_app_session.c index 5c0c725..131b315 100644 --- a/src/libstack/osrf_app_session.c +++ b/src/libstack/osrf_app_session.c @@ -311,16 +311,21 @@ osrf_app_session* osrf_app_server_session_init( return NULL; } + int stateless = 0; + char* statel = osrf_settings_host_value("/apps/%s/stateless", our_app ); + if(statel) stateless = atoi(statel); + free(statel); + + session->request_queue = NULL; session->remote_id = strdup(remote_id); session->orig_remote_id = strdup(remote_id); session->session_id = strdup(session_id); session->remote_service = strdup(our_app); + session->stateless = stateless; #ifdef ASSUME_STATELESS session->stateless = 1; - #else - session->stateless = 0; #endif session->thread_trace = 0; diff --git a/src/libstack/osrf_prefork.c b/src/libstack/osrf_prefork.c index 477b0dc..0ac0f84 100644 --- a/src/libstack/osrf_prefork.c +++ b/src/libstack/osrf_prefork.c @@ -13,7 +13,7 @@ int osrf_prefork_run(char* appname) { if(!appname) fatal_handler("osrf_prefork_run requires an appname to run!"); - set_proc_title( "opensrf listener [%s]", appname ); + set_proc_title( "OpenSRF Listener [%s]", appname ); int maxr = 1000; int maxc = 10; @@ -25,6 +25,7 @@ int osrf_prefork_run(char* appname) { jsonObject* min_children = osrf_settings_host_value_object("/apps/%s/unix_config/min_children", appname); jsonObject* max_children = osrf_settings_host_value_object("/apps/%s/unix_config/max_children", appname); + if(!max_req) warning_handler("Max requests not defined, assuming 1000"); else maxr = (int) jsonObjectGetNumber(max_req); @@ -105,7 +106,7 @@ void prefork_child_init_hook(prefork_child* child) { fatal_handler("Unable to bootstrap client for osrf_prefork_run()"); free(resc); - set_proc_title( "opensrf drone [%s]", child->appname ); + set_proc_title( "OpenSRF Drone [%s]", child->appname ); } void prefork_child_process_request(prefork_child* child, char* data) { @@ -116,10 +117,11 @@ void prefork_child_process_request(prefork_child* child, char* data) { osrfAppSession* session = osrf_stack_transport_handler(msg, child->appname); - if( ! session->stateless ) { /* keepalive loop for stateful sessions */ + if( session->stateless && session->state != OSRF_SESSION_CONNECTED ) return; + + /* keepalive loop for stateful sessions */ debug_handler("Entering keepalive loop for session %s", session->session_id ); - } } diff --git a/src/perlmods/OpenSRF/System.pm b/src/perlmods/OpenSRF/System.pm index 8d4e1b1..b657857 100644 --- a/src/perlmods/OpenSRF/System.pm +++ b/src/perlmods/OpenSRF/System.pm @@ -128,7 +128,7 @@ sub bootstrap { # Start a process group and make me the captain setpgrp( 0, 0 ); - $0 = "System"; + $0 = "OpenSRF System"; # ----------------------------------------------- # Launch the settings sever if necessary... diff --git a/src/router/Makefile b/src/router/Makefile index 256c594..a0a3330 100644 --- a/src/router/Makefile +++ b/src/router/Makefile @@ -3,13 +3,15 @@ LDLIBS += -lxml2 -lopensrf -lobjson CFLAGS += -D_ROUTER -all: router +all: opensrf_router install: - cp router $(BINDIR) + cp opensrf_router $(BINDIR) -router: router.o +opensrf_router: router.o + $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) router.o -o $@ router.o: router.c router.h clean: - /bin/rm -f *.o router + /bin/rm -f *.o opensrf_router + diff --git a/src/router/router.c b/src/router/router.c index 810fbb6..386fac0 100644 --- a/src/router/router.c +++ b/src/router/router.c @@ -27,6 +27,9 @@ int main( int argc, char* argv[] ) { osrfConfig* cfg = osrfConfigInit( argv[1], "router" ); osrfConfigSetDefaultConfig(cfg); + init_proc_title( argc, argv ); + set_proc_title( "OpenSRF Router" ); + /* load the config options */ char* server = osrfConfigGetValue(NULL, "/transport/server"); char* port = osrfConfigGetValue(NULL, "/transport/port"); diff --git a/src/utils/utils.h b/src/utils/utils.h index 96295a6..6074499 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -75,7 +75,14 @@ GNU General Public License for more details. #define BUFFER_MAX_SIZE 10485760 -/* these are evil and should be condemned */ +/* these are evil and should be condemned + ! Only use these if you are done with argv[]. + call init_proc_title() first, then call + set_proc_title. + the title is only allowed to be as big as the + initial process name of the process (full size of argv[]). + truncation may occurr. + */ int init_proc_title( int argc, char* argv[] ); int set_proc_title( char* format, ... );