Possible compatibility problems with earlier versions marked with '*'.
+Added option -p <file> to make Generic Frontend Server to write PID file.
+
+Added option -D to put Generic Frontend Server in background on its own.
+
Make ZOOM C recognize option "password". If unset, "pass" is used
(for backwards compatibility).
-<!-- $Id: frontend.xml,v 1.20 2003-11-25 19:46:18 adam Exp $ -->
+<!-- $Id: frontend.xml,v 1.21 2004-01-17 01:20:12 adam Exp $ -->
<chapter id="server"><title>Generic server</title>
<sect1><title>Introduction</title>
<arg choice="opt"><option>-k <replaceable>kilobytes</replaceable></option></arg>
<arg choice="opt"><option>-d <replaceable>daemon</replaceable></option></arg>
<arg choice="opt"><option>-w <replaceable>dir</replaceable></option></arg>
- <arg choice="opt"><option>-ziST1</option></arg>
+ <arg choice="opt"><option>-p <replaceable>pidfile</replaceable></option></arg>
+ <arg choice="opt"><option>-ziDST1</option></arg>
<arg choice="opt" rep="repeat">listener-spec</arg>
</cmdsynopsis>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
<!ENTITY ztest-options SYSTEM "ztest-options.xml">
]>
-<!-- $Id: yaz-ztest-man.xml,v 1.2 2003-11-25 19:46:18 adam Exp $ -->
+<!-- $Id: yaz-ztest-man.xml,v 1.3 2004-01-17 01:20:12 adam Exp $ -->
<refentry id="yaz-ztest">
<refmeta>
<arg choice="opt"><option>-k <replaceable>kilobytes</replaceable></option></arg>
<arg choice="opt"><option>-d <replaceable>daemon</replaceable></option></arg>
<arg choice="opt"><option>-w <replaceable>dir</replaceable></option></arg>
- <arg choice="opt"><option>-ziST1</option></arg>
+ <arg choice="opt"><option>-p <replaceable>pidfile</replaceable></option></arg>
+ <arg choice="opt"><option>-ziDST1</option></arg>
<arg choice="opt" rep="repeat">listener-spec</arg>
</cmdsynopsis>
<!--
- $Id: ztest-options.xml,v 1.3 2003-11-25 19:46:18 adam Exp $
+ $Id: ztest-options.xml,v 1.4 2004-01-17 01:20:12 adam Exp $
Options for generic frontend server and yaz-ztest.
Included in both manual and man page for yaz-ztest
-->
daemon (see <literal>-i</literal>).
</para></listitem></varlistentry>
+ <varlistentry><term><literal>-p </literal>
+ <replaceable>pidfile</replaceable></term>
+ <listitem><para>
+ Specifies that the server should write its Process ID to
+ file given by <replaceable>pidfile</replaceable>.
+ A typical location would be <filename>/var/run/yaz-ztest.pid</filename>.
+ </para></listitem></varlistentry>
+
<varlistentry><term><literal>-i</literal></term>
<listitem><para>
Use this to make the the server run from the
<application>inetd</application> server (UNIX only).
</para></listitem></varlistentry>
+ <varlistentry><term><literal>-D</literal></term>
+ <listitem><para>
+ Use this to make the server put itself in the background and
+ run as a daemon. If neither <literal>-i</literal> nor
+ <literal>-D</literal> is given, the server starts in the foreground.
+ </para></listitem></varlistentry>
+
<varlistentry><term><literal>-install</literal></term>
<listitem><para>
Use this to install the server as an NT service
/*
- * Copyright (c) 1995-2003, Index Data.
+ * Copyright (c) 1995-2004, Index Data.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation, in whole or in part, for any purpose, is hereby granted,
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: backend.h,v 1.22 2003-12-29 14:54:33 adam Exp $
+ * $Id: backend.h,v 1.23 2004-01-17 01:20:12 adam Exp $
*/
#ifndef BACKEND_H
char service_display_name[128]; /* The service display name */
#endif /* WIN32 */
struct bend_soap_handler *soap_handlers;
+ char pid_fname[128]; /* pid fname */
+ int background; /* auto daemon */
} statserv_options_block;
YAZ_EXPORT int statserv_main(
/*
- * Copyright (c) 1995-2003, Index Data
+ * Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* NT threaded server code by
* Chas Woodfield, Fretwell Downing Informatics.
*
- * $Id: statserv.c,v 1.3 2004-01-15 10:05:56 adam Exp $
+ * $Id: statserv.c,v 1.4 2004-01-17 01:20:13 adam Exp $
*/
#include <stdio.h>
"", /* NT Service Dependencies */
"Z39.50 Server", /* NT Service Display Name */
#endif /* WIN32 */
- 0 /* SOAP handlers */
+ 0, /* SOAP handlers */
+ "", /* PID fname */
+ 0 /* background daemon */
};
static int max_sessions = 0;
int statserv_start(int argc, char **argv)
{
- int ret;
+ int ret = 0;
#ifdef WIN32
/* We need to initialize the thread list */
(*control_block.bend_start)(&control_block);
#ifdef WIN32
yaz_log (LOG_LOG, "Starting server %s", me);
+ if (!pListener && *control_block.default_listen)
+ add_listener(control_block.default_listen,
+ control_block.default_proto);
+
+ if (!pListener)
+ return 1;
#else
/* UNIX */
if (control_block.inetd)
inetd_connection(control_block.default_proto);
else
{
+ if (!pListener && *control_block.default_listen)
+ add_listener(control_block.default_listen,
+ control_block.default_proto);
+
+ if (!pListener)
+ return 1;
+
+ if (*control_block.pid_fname)
+ {
+ FILE *f = fopen(control_block.pid_fname, "w");
+ if (!f)
+ {
+ yaz_log(LOG_FATAL|LOG_ERRNO, "Couldn't create %s",
+ control_block.pid_fname);
+ exit(0);
+ }
+ fprintf(f, "%ld", (long) getpid());
+ fclose(f);
+ }
+
yaz_log (LOG_LOG, "Starting server %s pid=%d", me, getpid());
#if 0
sigset_t sigs_to_block;
exit(1);
}
}
+ if (!control_block.inetd && control_block.background)
+ {
+ switch (fork())
+ {
+ case 0:
+ break;
+ case -1:
+ return 1;
+ default:
+ _exit(0);
+ }
+
+ if (setsid() < 0)
+ return 1;
+
+ close(0);
+ close(1);
+ close(2);
+ open("/dev/null",O_RDWR);
+ dup(0); dup(0);
+ }
/* UNIX */
#endif
-
-
if ((pListener == NULL) && *control_block.default_listen)
add_listener(control_block.default_listen,
control_block.default_proto);
int ret = 0, r;
char *arg;
- while ((ret = options("1a:iszSTl:v:u:c:w:t:k:d:D:", argv, argc, &arg)) != -2)
+ while ((ret = options("1a:iszSTl:v:u:c:w:t:k:d:A:p:D", argv, argc, &arg)) != -2)
{
switch (ret)
{
return 1;
}
break;
- case 'D':
+ case 'A':
max_sessions = atoi(arg);
break;
+ case 'p':
+ if (strlen(arg) >= sizeof(control_block.pid_fname))
+ {
+ yaz_log(LOG_FATAL, "pid fname too long");
+ exit(1);
+ }
+ strcpy(control_block.pid_fname, arg);
+ break;
+ case 'D':
+ control_block.background = 1;
+ break;
default:
fprintf(stderr, "Usage: %s [ -a <pdufile> -v <loglevel>"
" -l <logfile> -u <user> -c <config> -t <minutes>"
- " -k <kilobytes> -d <daemon>"
- " -ziST1 -w <directory> <listener-addr>... ]\n", me);
+ " -k <kilobytes> -d <daemon> -p <pidfile>"
+ " -ziDST1 -w <directory> <listener-addr>... ]\n", me);
return 1;
}
}