r4526 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Feb 1 22:06:31 CET 2010


Author: phk
Date: 2010-02-01 22:06:30 +0100 (Mon, 01 Feb 2010)
New Revision: 4526

Modified:
   trunk/varnish-cache/bin/varnishd/mgt.h
   trunk/varnish-cache/bin/varnishd/mgt_param.c
   trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
Add a secret, and decisively undocumented -x option to varnishd,
which only does something if -DDIAGNOSTIC was configured.

First secret superpower is "-x dumpmdoc" which emits a -mdoc suitable
table of all run-time parameters, which can be absorbed into the
varnishd.1 manual page, so we do not have to maintain the text in
two different places.



Modified: trunk/varnish-cache/bin/varnishd/mgt.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt.h	2010-02-01 20:08:18 UTC (rev 4525)
+++ trunk/varnish-cache/bin/varnishd/mgt.h	2010-02-01 21:06:30 UTC (rev 4526)
@@ -63,6 +63,7 @@
 void MCF_ParamSync(void);
 void MCF_ParamInit(struct cli *);
 void MCF_ParamSet(struct cli *, const char *param, const char *val);
+void MCF_DumpMdoc(void);
 
 /* mgt_vcc.c */
 void mgt_vcc_init(void);

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c	2010-02-01 20:08:18 UTC (rev 4525)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c	2010-02-01 21:06:30 UTC (rev 4526)
@@ -1022,3 +1022,66 @@
 
 	params = &master;
 }
+
+/*--------------------------------------------------------------------*/
+
+#ifdef DIAGNOSTICS
+
+void
+MCF_DumpMdoc(void)
+{
+	const struct parspec *pp;
+	const char *p, *q;
+	int i;
+
+	printf(".Bl -tag -width 4n\n");
+	for (i = 0; i < nparspec; i++) {
+		pp = parspec[i];
+		printf(".It Va %s\n", pp->name);
+		if (pp->units != NULL && *pp->units != '\0')
+			printf("Units:\n.Dv %s\n.br\n", pp->units);
+		printf("Default:\n.Dv %s\n.br\n", pp->def);
+		/*
+		 * XXX: we should mark the params with one/two flags
+		 * XXX: that say if ->min/->max are valid, so we
+		 * XXX: can emit those also in help texts.
+		 */
+		if (pp->flags) {
+			printf("Flags:\n.Dv \"");
+			q = "";
+			if (pp->flags & DELAYED_EFFECT) {
+				printf("%sdelayed", q);
+				q = ", ";
+			}
+			if (pp->flags & MUST_RESTART) {
+				printf("%smust_restart", q);
+				q = ", ";
+			}
+			if (pp->flags & MUST_RELOAD) {
+				printf("%smust_reload", q);
+				q = ", ";
+			}
+			if (pp->flags & EXPERIMENTAL) {
+				printf("%sexperimental", q);
+				q = ", ";
+			}
+			printf("\"\n.br\n");
+		}
+		printf(".Pp\n");
+		for (p = pp->descr; *p; p++) {
+			if (*p == '\n' && p[1] =='\0') 
+				break;
+			if (*p == '\n' && p[1] =='\n') {
+				printf("\n.Pp\n");
+				p++;
+			} else if (*p == '\n') {
+				printf("\n.br\n");
+			} else {
+				printf("%c", *p);
+			}
+		}
+		printf("\n.Pp\n");
+	}
+	printf(".El\n");
+}
+#endif /* DIAGNOSTICS */

Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c	2010-02-01 20:08:18 UTC (rev 4525)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c	2010-02-01 21:06:30 UTC (rev 4526)
@@ -582,7 +582,7 @@
 	cli_check(cli);
 
 	while ((o = getopt(argc, argv,
-	    "a:b:Cdf:Fg:h:i:l:M:n:P:p:S:s:T:t:u:Vw:")) != -1)
+	    "a:b:Cdf:Fg:h:i:l:M:n:P:p:S:s:T:t:u:Vx:w:")) != -1)
 		switch (o) {
 		case 'a':
 			MCF_ParamSet(cli, "listen_address", optarg);
@@ -652,6 +652,15 @@
 		case 'V':
 			varnish_version("varnishd");
 			exit(0);
+		case 'x':
+#ifdef DIAGNOSTICS
+			if (!strcmp(optarg, "dumpmdoc")) {
+				MCF_DumpMdoc();
+				exit (0);
+			}
+#endif /* DIAGNOSTICS */
+			usage();
+			break;
 		case 'w':
 			tackle_warg(optarg);
 			break;



More information about the varnish-commit mailing list