From bda1da92c14ac0dc9c645a2fa5c3ad5ce2b383c9 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 11 Jun 2018 11:12:26 -0400 Subject: [PATCH] Websocket stdio / websocketd experiment Signed-off-by: Bill Erickson --- src/websocket-stdio/osrf-websocket-stdio.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/websocket-stdio/osrf-websocket-stdio.c b/src/websocket-stdio/osrf-websocket-stdio.c index 68cde32..3ea2825 100644 --- a/src/websocket-stdio/osrf-websocket-stdio.c +++ b/src/websocket-stdio/osrf-websocket-stdio.c @@ -23,6 +23,11 @@ * * Built to function with websocketd: * https://github.com/joewalnes/websocketd + * + * Synopsis: + * + * websocketd --port 7684 --max-forks 250 ./osrf-websocket-stdio /path/to/opensrf_core.xml & + * */ #include @@ -58,7 +63,7 @@ #define RESET_MESSAGE_SIZE 102400 // default values, replaced during setup (below) as needed. -static char* config_file = "/openils/conf/opensrf_core.xml"; // TODO +static char* config_file = "/openils/conf/opensrf_core.xml"; static char* config_ctxt = "gateway"; static char* osrf_router = NULL; static char* osrf_domain = NULL; @@ -72,7 +77,7 @@ static char recipient_buf[RECIP_BUF_SIZE]; // reusable recipient buffer static char* client_ip = NULL; static void rebuild_stdin_buffer(); -static void child_init(); +static void child_init(int argc, char* argv[]); static void read_from_stdin(); static void relay_stdin_message(const char*); static char* extract_inbound_messages(); @@ -87,7 +92,7 @@ static void sigint_handler(int sig) { shut_it_down(0); } -int main() { +int main(int argc, char* argv[]) { // Handle shutdown signal signal(SIGINT, sigint_handler); @@ -96,7 +101,7 @@ int main() { // Connect to OpenSRF // exits on error. - child_init(); + child_init(argc, argv); // Disable output buffering. setbuf(stdout, NULL); @@ -170,7 +175,11 @@ static int shut_it_down(int stat) { // Connect to opensrf -static void child_init() { +static void child_init(int argc, char* argv[]) { + + if (argc > 1) { + config_file = argv[1]; + } if (!osrf_system_bootstrap_client(config_file, config_ctxt) ) { fprintf(stderr, "Cannot boostrap OSRF\n"); -- 2.11.0