X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fpazpar2.c;h=b3928aa4628efaa1c1b314603c713f5bd63edd3a;hb=dfa3f5aa5c191a7e528e09789fce3d82d62c8e51;hp=6afccf13acd49e0086dad5a84165b7ad55d69b84;hpb=8961ed761e348e972f00d015284ce75c16b1648c;p=pazpar2-moved-to-github.git diff --git a/src/pazpar2.c b/src/pazpar2.c index 6afccf1..b3928aa 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2012 Index Data + Copyright (C) Index Data Pazpar2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include // #define MTRACE #ifdef MTRACE @@ -57,7 +58,7 @@ void child_handler(void *data) static void show_version(void) { - char yaz_version_str[80]; + char yaz_version_str[20]; printf("Pazpar2 " PACKAGE_VERSION #ifdef PAZPAR2_VERSION_SHA1 " " @@ -108,6 +109,9 @@ static int sc_main( struct conf_config *config = 0; int test_mode = 0; + xmlInitParser(); + LIBXML_TEST_VERSION + #ifndef WIN32 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) yaz_log(YLOG_WARN|YLOG_ERRNO, "signal"); @@ -118,7 +122,9 @@ static int sc_main( yaz_log_init_prefix("pazpar2"); yaz_log_xml_errors(0, YLOG_WARN); - while ((ret = options("dDf:h:l:p:R:tu:v:Vw:X", argv, argc, &arg)) != -2) + yaz_enable_panic_backtrace(argv[0]); + + while ((ret = options("dDf:h:l:m:p:R:tu:v:Vw:X", argv, argc, &arg)) != -2) { switch (ret) { @@ -138,6 +144,9 @@ static int sc_main( yaz_log_init_file(arg); log_file_in_use = 1; break; + case 'm': + yaz_log_time_format(arg); + break; case 'p': pidfile = arg; break; @@ -181,6 +190,7 @@ static int sc_main( " -f configfile Configuration\n" " -h [host:]port Listener port\n" " -l file Log to file\n" + " -m logformat log time format (strftime)\n" " -p pidfile PID file\n" " -R recfile HTTP recording file\n" " -t Test configuration\n" @@ -204,7 +214,21 @@ static int sc_main( } pazpar2_mutex_init(); - config = config_create(config_fname, global_parameters.dump_records); + { + char yaz_version_str[20]; + char yaz_sha1_str[41]; + yaz_log(YLOG_LOG, "Pazpar2 %s " VERSION " " +#ifdef PAZPAR2_VERSION_SHA1 + PAZPAR2_VERSION_SHA1 +#else + "-" +#endif + , test_mode ? "test" : "start"); + yaz_version(yaz_version_str, yaz_sha1_str); + yaz_log(YLOG_LOG, "YAZ %s %s", yaz_version_str, yaz_sha1_str); + } + + config = config_create(config_fname); if (!config) return 1; sc_stop_config = config; @@ -215,30 +239,27 @@ static int sc_main( } else { - yaz_log(YLOG_LOG, "Pazpar2 " VERSION " " -#ifdef PAZPAR2_VERSION_SHA1 - PAZPAR2_VERSION_SHA1 -#else - "-" -#endif - " started"); + ret = 0; if (daemon && !log_file_in_use) { yaz_log(YLOG_FATAL, "Logfile must be given (option -l) for daemon " "mode"); - return 1; + ret = 1; } - ret = config_start_listeners(config, listener_override, record_fname); - if (ret) - return ret; /* error starting http listener */ - - yaz_sc_running(s); - - yaz_daemon("pazpar2", - (global_parameters.debug_mode ? YAZ_DAEMON_DEBUG : 0) + - (daemon ? YAZ_DAEMON_FORK : 0) + YAZ_DAEMON_KEEPALIVE, - child_handler, config /* child_data */, - pidfile, uid); + if (!ret) + ret = config_start_listeners(config, listener_override, + record_fname); + if (!ret) + { + yaz_sc_running(s); + yaz_daemon("pazpar2", + (global_parameters.debug_mode ? YAZ_DAEMON_DEBUG : 0) + + (daemon ? YAZ_DAEMON_FORK : 0) + YAZ_DAEMON_KEEPALIVE, + child_handler, config /* child_data */, + pidfile, uid); + } + yaz_log(YLOG_LOG, "Pazpar2 stop"); + return ret; } return 0; }