1 /* This file is part of Pazpar2.
2 Copyright (C) 2006-2008 Index Data
4 Pazpar2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #include <yaz/daemon.h>
33 void child_handler(void *data)
38 if (*global_parameters.settings_path_override)
39 settings_read(global_parameters.settings_path_override);
40 else if (global_parameters.server->settings)
41 settings_read(global_parameters.server->settings);
43 yaz_log(YLOG_WARN, "No settings-directory specified");
44 global_parameters.odr_in = odr_createmem(ODR_DECODE);
45 global_parameters.odr_out = odr_createmem(ODR_ENCODE);
52 static void show_version(void)
54 char yaz_version_str[80];
55 printf("Pazpar2 " PACKAGE_VERSION "\n");
57 yaz_version(yaz_version_str, 0);
59 printf("Configuration:");
63 printf(" yaz:%s", yaz_version_str);
68 int main(int argc, char **argv)
72 int log_file_in_use = 0;
74 const char *pidfile = 0;
78 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
79 yaz_log(YLOG_WARN|YLOG_ERRNO, "signal");
82 yaz_log_init_prefix("pazpar2");
83 #if YAZ_VERSIONL >= 0x03001B
84 yaz_log_xml_errors(0, YLOG_WARN);
87 while ((ret = options("dDf:h:l:p:t:u:VX", argv, argc, &arg)) != -2)
92 global_parameters.dump_records = 1;
98 if (!read_config(arg))
102 strcpy(global_parameters.listener_override, arg);
105 yaz_log_init_file(arg);
112 strcpy(global_parameters.settings_path_override, arg);
120 global_parameters.debug_mode = 1;
123 fprintf(stderr, "Usage: pazpar2\n"
124 " -d (show internal records)\n"
125 " -D Daemon mode (background)\n"
127 " -h [host:]port (REST protocol listener)\n"
128 " -l file log to file\n"
129 " -p pidfile PID file\n"
139 yaz_log(YLOG_LOG, "Pazpar2 %s started", VERSION);
140 if (daemon && !log_file_in_use)
142 yaz_log(YLOG_FATAL, "Logfile must be given (option -l) for daemon "
148 yaz_log(YLOG_FATAL, "Load config with -f");
151 global_parameters.server = config->servers;
153 start_http_listener();
154 yaz_daemon("pazpar2",
155 (global_parameters.debug_mode ? YAZ_DAEMON_DEBUG : 0) +
156 (daemon ? YAZ_DAEMON_FORK : 0) + YAZ_DAEMON_KEEPALIVE,
157 child_handler, 0 /* child_data */,
166 * indent-tabs-mode: nil
168 * vim: shiftwidth=4 tabstop=8 expandtab