mirror of https://github.com/omar-polo/gmid.git
reopen log files upon SIGUSR2
This commit is contained in:
parent
60b4efa1e2
commit
3bda540e34
4
gmid.8
4
gmid.8
|
@ -32,7 +32,9 @@ talk to FastCGI applications and act as a gemini reverse proxy.
|
|||
.Pp
|
||||
.Nm
|
||||
rereads the configuration file when it receives
|
||||
.Dv SIGHUP .
|
||||
.Dv SIGHUP
|
||||
and reopens log files when it receives
|
||||
.Dv SIGUSR1 .
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width 14m
|
||||
|
|
36
gmid.c
36
gmid.c
|
@ -299,11 +299,13 @@ main(int argc, char **argv)
|
|||
signal_set(&ps->ps_evsigterm, SIGTERM, main_sig_handler, ps);
|
||||
signal_set(&ps->ps_evsigchld, SIGCHLD, main_sig_handler, ps);
|
||||
signal_set(&ps->ps_evsighup, SIGHUP, main_sig_handler, ps);
|
||||
signal_set(&ps->ps_evsigusr1, SIGUSR1, main_sig_handler, ps);
|
||||
|
||||
signal_add(&ps->ps_evsigint, NULL);
|
||||
signal_add(&ps->ps_evsigterm, NULL);
|
||||
signal_add(&ps->ps_evsigchld, NULL);
|
||||
signal_add(&ps->ps_evsighup, NULL);
|
||||
signal_add(&ps->ps_evsigusr1, NULL);
|
||||
|
||||
proc_connect(ps);
|
||||
|
||||
|
@ -316,20 +318,33 @@ main(int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
main_send_logfd(struct conf *conf)
|
||||
{
|
||||
struct privsep *ps = conf->ps;
|
||||
int fd = -1;
|
||||
|
||||
if (debug)
|
||||
return 0;
|
||||
|
||||
if (conf->log_access) {
|
||||
fd = open(conf->log_access, O_WRONLY|O_CREAT|O_APPEND, 0600);
|
||||
if (fd == -1)
|
||||
log_warn("can't open %s", conf->log_access);
|
||||
}
|
||||
if (proc_compose_imsg(ps, PROC_LOGGER, -1, IMSG_LOG_TYPE, -1, fd,
|
||||
NULL, 0) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
main_configure(struct conf *conf)
|
||||
{
|
||||
struct privsep *ps = conf->ps;
|
||||
int fd = -1;
|
||||
|
||||
if (!debug) {
|
||||
if (conf->log_access && (fd = open(conf->log_access,
|
||||
O_WRONLY|O_CREAT|O_APPEND, 0600)) == -1)
|
||||
log_warn("can't open %s", conf->log_access);
|
||||
if (proc_compose_imsg(ps, PROC_LOGGER, -1, IMSG_LOG_TYPE,
|
||||
-1, fd, NULL, 0) == -1)
|
||||
return -1;
|
||||
}
|
||||
if (main_send_logfd(conf) == -1)
|
||||
return -1;
|
||||
|
||||
conf->reload = conf->prefork + 1; /* servers, crypto */
|
||||
|
||||
|
@ -405,6 +420,9 @@ main_sig_handler(int sig, short ev, void *arg)
|
|||
case SIGINT:
|
||||
main_shutdown(ps->ps_env);
|
||||
break;
|
||||
case SIGUSR1:
|
||||
main_send_logfd(ps->ps_env);
|
||||
break;
|
||||
default:
|
||||
fatalx("unexpected signal %d", sig);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue