commit - 7957cbd9aad6ace179287b2ddcbae0b14a25a90d
commit + 46af8c6cfe1f1ec15d93bc58791f4596c610785b
blob - 4aff056d6605ac7c46cf82ca8a818e8eb72fb316
blob + 487afdd27f0a98a858342c49dc5edd6cb9e90b28
--- gmid.1
+++ gmid.1
.Sh SYNOPSIS
.Nm
.Bk -words
-.Op Fl n
+.Op Fl fn
.Op Fl c Ar config
|
.Op Fl 6h
available.
If a configuration file is given, no other flags shall be given,
except for
+.Fl f
+and
.Fl n .
.Pp
.Nm
.Bl -tag -width 14m
.It Fl c Pa config
Specify the configuration file.
+.It Fl f
+Stays and logs on the foreground.
.It Fl n
Check that the configuration is valid, but don't start the server.
.El
.Dq like this .
.Ss Global Options
.Bl -tag -width 12m
-.It Ic daemon Ar bool
-Enable or disables the daemon mode.
-In daemon mode
-.Nm
-will log to syslog and fork in the background.
-By default is on.
.It Ic ipv6 Ar bool
Enable or disable IPv6 support.
By default is off.
blob - 09a1d6fcfe20dc7f4b1feacd5e0027944c7b0e1d
blob + f9811b9299a58f40b069bfc26c9db82d3f729b26
--- gmid.c
+++ gmid.c
struct vhost hosts[HOSTSLEN];
-int goterror;
+int exfd, foreground, goterror;
-int exfd;
-
struct conf conf;
struct tls *ctx;
va_start(ap, fmt);
- if (conf.foreground) {
+ if (foreground) {
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
} else
if (vasprintf(&fmted, fmt, ap) == -1)
fatal("vasprintf: %s", strerror(errno));
- if (conf.foreground)
+ if (foreground)
fprintf(stderr, "%s:%s %s\n", hbuf, sbuf, fmted);
else {
if (asprintf(&s, "%s:%s %s", hbuf, sbuf, fmted) == -1)
if ((t = gmid_strnchr(meta, '\r', l)) == NULL)
t = meta + len;
- if (conf.foreground)
+ if (foreground)
fprintf(stderr, "%s:%s GET %s %.*s\n", hbuf, sbuf, b,
(int)(t - meta), meta);
else
int sock4, sock6;
load_default_mime(&conf.mime);
-
- if (!conf.foreground && daemon(0, 1) == -1)
- exit(1);
sock4 = make_socket(conf.port, AF_INET);
sock6 = -1;
for (i = 0; i < HOSTSLEN; ++i)
hosts[i].dirfd = -1;
- conf.foreground = 0;
conf.port = 1965;
conf.ipv6 = 0;
conf.protos = TLS_PROTOCOL_TLSv1_2 | TLS_PROTOCOL_TLSv1_3;
usage(const char *me)
{
fprintf(stderr,
- "USAGE: %s [-n] [-c config] | [-6h] [-d certs-dir] [-H host]"
+ "USAGE: %s [-fn] [-c config] | [-6h] [-d certs-dir] [-H host]"
" [-p port] [-x cgi] [dir]",
me);
}
init_config();
- while ((ch = getopt(argc, argv, "6c:d:H:hnp:x:")) != -1) {
+ while ((ch = getopt(argc, argv, "6c:d:fH:hnp:x:")) != -1) {
switch (ch) {
case '6':
conf.ipv6 = 1;
configless = 1;
break;
+ case 'f':
+ foreground = 1;
+ break;
+
case 'H':
hostname = optarg;
configless = 1;
parse_conf(config_path);
} else {
- conf.foreground = 1;
-
if (hostname == NULL)
hostname = "localhost";
if (certs_dir == NULL)
signal(SIGINFO, sig_handler);
#endif
signal(SIGUSR2, sig_handler);
+ signal(SIGHUP, SIG_IGN);
- if (!conf.foreground) {
- signal(SIGHUP, SIG_IGN);
+ if (!foreground && !configless) {
if (daemon(1, 1) == -1)
fatal("daemon: %s", strerror(errno));
}
blob - 47a053630219f8ad6fcf58063659192f45fcc53e
blob + 862792f230182cda45b185648eac56aabb4efe95
--- gmid.h
+++ gmid.h
};
struct conf {
- int foreground;
int port;
int ipv6;
uint32_t protos;
blob - 099b3c4b19d822ba495bb7d4980f114d99cbd54f
blob + f7e041d20e78bf48c7a58a601b7b971c85b95495
--- lex.l
+++ lex.l
on yylval.num = 1; return TBOOL;
off yylval.num = 0; return TBOOL;
-daemon return TDAEMON;
ipv6 return TIPV6;
port return TPORT;
protocols return TPROTOCOLS;
blob - 97934599fd9039217e0a83785418fb3fb5a25d6f
blob + 56a393577063eca8a92d8c78bb7c85f1941e56bd
--- parse.y
+++ parse.y
int num;
}
-%token TDAEMON TIPV6 TPORT TPROTOCOLS TMIME TDEFAULT TTYPE
+%token TIPV6 TPORT TPROTOCOLS TMIME TDEFAULT TTYPE
%token TCHROOT TUSER TSERVER
%token TLOCATION TCERT TKEY TROOT TCGI TLANG TINDEX TAUTO
%token TERR
| options option
;
-option : TDAEMON TBOOL { conf.foreground = !$2; }
- | TIPV6 TBOOL { conf.ipv6 = $2; }
+option : TIPV6 TBOOL { conf.ipv6 = $2; }
| TPORT TNUM { conf.port = $2; }
| TPROTOCOLS TSTRING {
if (tls_config_parse_protocols(&conf.protos, $2) == -1)
blob - ca87701f35435c53dcc1f64a02f7f06b21ff1509
blob + bc0f0eee574a4bd360e659e3c4c26ed9164098ed
--- regress/runtime
+++ regress/runtime
# generates a configuration file reg.conf
config() {
cat <<EOF > reg.conf
-daemon off
ipv6 off
port 10965
$1
run() {
# filter out logs for GET requests
- (./../gmid -c reg.conf 2>&1 | grep -v GET) >&2 &
+ (./../gmid -f -c reg.conf 2>&1 | grep -v GET) >&2 &
pid=$!
# give gmid time to bind the port, otherwise we end up
# executing gg when gmid isn't ready yet.