1 /* $Id: pazpar2.c,v 1.94 2008-02-18 19:33:32 adam Exp $
2 Copyright (c) 2006-2007, Index Data.
4 This file is part of Pazpar2.
6 Pazpar2 is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with Pazpar2; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
33 #include <yaz/daemon.h>
35 void child_handler(void *data)
40 if (*global_parameters.settings_path_override)
41 settings_read(global_parameters.settings_path_override);
42 else if (global_parameters.server->settings)
43 settings_read(global_parameters.server->settings);
45 yaz_log(YLOG_WARN, "No settings-directory specified");
46 global_parameters.odr_in = odr_createmem(ODR_DECODE);
47 global_parameters.odr_out = odr_createmem(ODR_ENCODE);
54 static void show_version(void)
56 char yaz_version_str[80];
57 printf("Pazpar2 " VERSION "\n");
59 yaz_version(yaz_version_str, 0);
61 printf("Configuration:");
65 printf(" yaz:%s", yaz_version_str);
70 int main(int argc, char **argv)
74 int log_file_in_use = 0;
76 const char *pidfile = 0;
79 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
80 yaz_log(YLOG_WARN|YLOG_ERRNO, "signal");
82 yaz_log_init_prefix("pazpar2");
84 while ((ret = options("dDf:h:l:p:t:u:VX", argv, argc, &arg)) != -2)
89 global_parameters.dump_records = 1;
95 if (!read_config(arg))
99 strcpy(global_parameters.listener_override, arg);
102 yaz_log_init_file(arg);
109 strcpy(global_parameters.settings_path_override, arg);
117 global_parameters.debug_mode = 1;
120 fprintf(stderr, "Usage: pazpar2\n"
121 " -d (show internal records)\n"
122 " -D Daemon mode (background)\n"
124 " -h [host:]port (REST protocol listener)\n"
125 " -l file log to file\n"
126 " -p pidfile PID file\n"
136 yaz_log(YLOG_LOG, "Pazpar2 %s started", VERSION);
137 if (daemon && !log_file_in_use)
139 yaz_log(YLOG_FATAL, "Logfile must be given (option -l) for daemon "
145 yaz_log(YLOG_FATAL, "Load config with -f");
148 global_parameters.server = config->servers;
150 start_http_listener();
151 yaz_daemon("pazpar2",
152 (global_parameters.debug_mode ? YAZ_DAEMON_DEBUG : 0) +
153 (daemon ? YAZ_DAEMON_FORK : 0) + YAZ_DAEMON_KEEPALIVE,
154 child_handler, 0 /* child_data */,
163 * indent-tabs-mode: nil
165 * vim: shiftwidth=4 tabstop=8 expandtab