mirror of
https://github.com/omar-polo/gmid.git
synced 2024-09-27 21:11:51 +02:00
pidfile support with `-P pidfile'
This commit is contained in:
parent
2ef7f631db
commit
8e8b2e252c
@ -1,3 +1,7 @@
|
|||||||
|
2021-04-28 Omar Polo <op@omarpolo.com>
|
||||||
|
|
||||||
|
* gmid.c (main): pidfile support with `-P pidfile'
|
||||||
|
|
||||||
2021-04-27 Omar Polo <op@omarpolo.com>
|
2021-04-27 Omar Polo <op@omarpolo.com>
|
||||||
|
|
||||||
* parse.y (servopt): added ``env'' option to define environment vars for CGI scripts
|
* parse.y (servopt): added ``env'' option to define environment vars for CGI scripts
|
||||||
|
5
gmid.1
5
gmid.1
@ -22,6 +22,7 @@
|
|||||||
.Bk -words
|
.Bk -words
|
||||||
.Op Fl fnv
|
.Op Fl fnv
|
||||||
.Op Fl c Ar config
|
.Op Fl c Ar config
|
||||||
|
.Op Fl P Ar pidfile
|
||||||
.Ek
|
.Ek
|
||||||
.Nm
|
.Nm
|
||||||
.Bk -words
|
.Bk -words
|
||||||
@ -51,6 +52,10 @@ Specify the configuration file.
|
|||||||
Stays and logs on the foreground.
|
Stays and logs on the foreground.
|
||||||
.It Fl n
|
.It Fl n
|
||||||
Check that the configuration is valid, but don't start the server.
|
Check that the configuration is valid, but don't start the server.
|
||||||
|
.It Fl P Pa pidfile
|
||||||
|
Write
|
||||||
|
.Nm
|
||||||
|
pid to the given path.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
If no configuration file is given,
|
If no configuration file is given,
|
||||||
|
17
gmid.c
17
gmid.c
@ -328,7 +328,7 @@ static void
|
|||||||
usage(const char *me)
|
usage(const char *me)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"USAGE: %s [-fn] [-c config] | [-6h] [-d certs-dir] [-H host]\n"
|
"USAGE: %s [-fn] [-c config] [-P pidfile] | [-6h] [-d certs-dir] [-H host]\n"
|
||||||
" [-p port] [-x cgi] [dir]\n",
|
" [-p port] [-x cgi] [dir]\n",
|
||||||
me);
|
me);
|
||||||
}
|
}
|
||||||
@ -474,12 +474,12 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
struct imsgbuf exibuf;
|
struct imsgbuf exibuf;
|
||||||
int ch, conftest = 0, configless = 0;
|
int ch, conftest = 0, configless = 0;
|
||||||
int old_ipv6, old_port;
|
int pidfd, old_ipv6, old_port;
|
||||||
const char *cgi = NULL;
|
const char *pidfile = NULL, *cgi = NULL;
|
||||||
|
|
||||||
init_config();
|
init_config();
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "6c:d:fH:hnp:vx:")) != -1) {
|
while ((ch = getopt(argc, argv, "6c:d:fH:hnP:p:vx:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '6':
|
case '6':
|
||||||
conf.ipv6 = 1;
|
conf.ipv6 = 1;
|
||||||
@ -512,6 +512,10 @@ main(int argc, char **argv)
|
|||||||
conftest = 1;
|
conftest = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'P':
|
||||||
|
pidfile = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
conf.port = parse_portno(optarg);
|
conf.port = parse_portno(optarg);
|
||||||
configless = 1;
|
configless = 1;
|
||||||
@ -576,6 +580,8 @@ main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pidfd = write_pidfile(pidfile);
|
||||||
|
|
||||||
/* Linux seems to call the event handlers even when we're
|
/* Linux seems to call the event handlers even when we're
|
||||||
* doing a sigwait. These dummy handlers are here to avoid
|
* doing a sigwait. These dummy handlers are here to avoid
|
||||||
* being terminated on SIGHUP, SIGINT or SIGTERM. */
|
* being terminated on SIGHUP, SIGINT or SIGTERM. */
|
||||||
@ -644,5 +650,8 @@ main(int argc, char **argv)
|
|||||||
imsg_compose(&logibuf, IMSG_QUIT, 0, 0, -1, NULL, 0);
|
imsg_compose(&logibuf, IMSG_QUIT, 0, 0, -1, NULL, 0);
|
||||||
imsg_flush(&logibuf);
|
imsg_flush(&logibuf);
|
||||||
|
|
||||||
|
if (pidfd != -1)
|
||||||
|
close(pidfd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user