static void childInit(apr_pool_t *p, server_rec *s) { if(!osrfSystemBootstrapClientResc(configFile, configCtx, "translator")) { ap_log_error( APLOG_MARK, APLOG_ERR, 0, s, "Unable to Bootstrap OpenSRF Client with config %s..", configFile); return; } routerName = osrfConfigGetValue(NULL, "/router_name"); domainName = osrfConfigGetValue(NULL, "/domain"); const char* servers[] = {cacheServers}; osrfCacheInit(servers, 1, 86400); osrfConnected = 1; allowedOrigins = osrfNewStringArray(4); osrfConfigGetValueList(NULL, allowedOrigins, "/cross_origin/origin"); // at pool destroy time (= child exit time), cleanup // XXX causes us to disconnect even for clone()'d process cleanup (as in mod_cgi) //apr_pool_cleanup_register(p, NULL, childExit, apr_pool_cleanup_null); }
static void osrf_json_gateway_child_init(apr_pool_t *p, server_rec *s) { char* cfg = osrf_json_gateway_config_file; char buf[32]; int t = time(NULL); snprintf(buf, sizeof(buf), "%d", t); if( ! osrfSystemBootstrapClientResc( cfg, CONFIG_CONTEXT, buf ) ) { ap_log_error( APLOG_MARK, APLOG_ERR, 0, s, "Unable to Bootstrap OpenSRF Client with config %s..", cfg); return; } bootstrapped = 1; osrfLogInfo(OSRF_LOG_MARK, "Bootstrapping gateway child for requests"); // when this pool is cleaned up, it means the child // process is going away. register some cleanup code // XXX causes us to disconnect even for clone()'d process cleanup (as in mod_cgi) //apr_pool_cleanup_register(p, NULL, child_exit, apr_pool_cleanup_null); }
/** * Connect to OpenSRF, create the main pool, responder thread * session cache and session pool. */ int child_init(const WebSocketServer *server) { request_rec *r = server->request(server); // osrf_handle will already be connected if this is not the first request // served by this process. if ( !(osrf_handle = osrfSystemGetTransportClient()) ) { // load config values from the env char* timeout = getenv("OSRF_WEBSOCKET_IDLE_TIMEOUT"); if (timeout) { if (!atoi(timeout)) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "WS: invalid OSRF_WEBSOCKET_IDLE_TIMEOUT: %s", timeout); } else { idle_timeout_interval = (time_t) atoi(timeout); } } ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "WS: timeout set to %d", idle_timeout_interval); timeout = getenv("OSRF_WEBSOCKET_MAX_REQUEST_WAIT_TIME"); if (timeout) { if (!atoi(timeout)) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "WS: invalid OSRF_WEBSOCKET_MAX_REQUEST_WAIT_TIME: %s", timeout ); } else { max_request_wait_time = (time_t) atoi(timeout); } } ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "WS: max request wait time set to %d", max_request_wait_time); char* interval = getenv("OSRF_WEBSOCKET_IDLE_CHECK_INTERVAL"); if (interval) { if (!atoi(interval)) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "WS: invalid OSRF_WEBSOCKET_IDLE_CHECK_INTERVAL: %s", interval ); } else { idle_check_interval = (time_t) atoi(interval); } } ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "WS: idle check interval set to %d", idle_check_interval); char* cfile = getenv("OSRF_WEBSOCKET_CONFIG_FILE"); if (cfile) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "WS: config file set to %s", cfile); config_file = cfile; } char* ctxt = getenv("OSRF_WEBSOCKET_CONFIG_CTXT"); if (ctxt) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "WS: config context set to %s", ctxt); config_ctxt = ctxt; } // connect to opensrf if (!osrfSystemBootstrapClientResc( config_file, config_ctxt, "websocket")) { osrfLogError(OSRF_LOG_MARK, "WS unable to bootstrap OpenSRF client with config %s " "and context %s", config_file, config_ctxt ); return 1; } osrfLogSetAppname("osrf_websocket_translator"); osrf_handle = osrfSystemGetTransportClient(); } signal(SIGUSR1, sigusr1_handler); return APR_SUCCESS; }