r3762 - in trunk/varnish-cache: bin/varnishd include
phk at projects.linpro.no
phk at projects.linpro.no
Fri Feb 13 11:13:27 CET 2009
Author: phk
Date: 2009-02-13 11:13:27 +0100 (Fri, 13 Feb 2009)
New Revision: 3762
Modified:
trunk/varnish-cache/bin/varnishd/heritage.h
trunk/varnish-cache/bin/varnishd/mgt_child.c
trunk/varnish-cache/bin/varnishd/mgt_cli.c
trunk/varnish-cache/bin/varnishd/mgt_param.c
trunk/varnish-cache/include/cli.h
Log:
Add a "banner" command to the CLI interface.
Add a parameter "cli_banner" (default on) which injects an implicit
"banner" CLI command on all cli connections when opened.
The net result is that you get a CLI response when you connect to
the CLI ports:
200 193
-----------------------------
Varnish HTTP accelerator CLI.
-----------------------------
Type 'help' for command list.
Type 'quit' to close CLI session.
Type 'start' to launch worker process.
Presently the contents of the CLI response is "undefined", in the
sense that you should not programatically depend on anything besides
the "200" reply code.
Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h 2009-02-13 09:49:11 UTC (rev 3761)
+++ trunk/varnish-cache/bin/varnishd/heritage.h 2009-02-13 10:13:27 UTC (rev 3762)
@@ -195,6 +195,9 @@
/* Get rid of duplicate purges */
unsigned purge_dups;
+
+ /* CLI banner */
+ unsigned cli_banner;
};
extern volatile struct params *params;
Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_child.c 2009-02-13 09:49:11 UTC (rev 3761)
+++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2009-02-13 10:13:27 UTC (rev 3762)
@@ -553,9 +553,7 @@
start_child(NULL);
if (child_state == CH_STOPPED)
exit(2);
- } else
- fprintf(stderr,
- "Debugging mode, enter \"start\" to start child\n");
+ }
i = vev_schedule(mgt_evb);
if (i != 0)
Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2009-02-13 09:49:11 UTC (rev 3761)
+++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2009-02-13 10:13:27 UTC (rev 3762)
@@ -126,9 +126,28 @@
/*--------------------------------------------------------------------*/
+static void
+mcf_banner(struct cli *cli, const char *const *av, void *priv)
+{
+
+ (void)av;
+ (void)priv;
+ cli_out(cli, "-----------------------------\n");
+ cli_out(cli, "Varnish HTTP accelerator CLI.\n");
+ cli_out(cli, "-----------------------------\n");
+ cli_out(cli, "Type 'help' for command list.\n");
+ cli_out(cli, "Type 'quit' to close CLI session.\n");
+ if (child_pid < 0)
+ cli_out(cli, "Type 'start' to launch worker process.\n");
+ cli_result(cli, CLIS_OK);
+}
+
+/*--------------------------------------------------------------------*/
+
/* XXX: what order should this list be in ? */
static struct cli_proto cli_proto[] = {
{ CLI_HELP, mcf_help, cli_proto },
+ { CLI_BANNER, mcf_banner, NULL },
{ CLI_PING, cli_func_ping },
{ CLI_SERVER_STATUS, mcf_server_status, NULL },
{ CLI_SERVER_START, mcf_server_startstop, NULL },
@@ -250,8 +269,6 @@
return (0);
cli_dispatch(cp->cli, cli_proto, p);
- vsb_finish(cp->cli->sb);
- AZ(vsb_overflowed(cp->cli->sb));
if (cp->cli->result == CLIS_UNKNOWN) {
/*
* Command not recognized in master, try cacher if it is
@@ -275,9 +292,9 @@
cli_out(cp->cli, "%s", q);
free(q);
}
- vsb_finish(cp->cli->sb);
- AZ(vsb_overflowed(cp->cli->sb));
}
+ vsb_finish(cp->cli->sb);
+ AZ(vsb_overflowed(cp->cli->sb));
/* send the result back */
syslog(LOG_INFO, "CLI %d result %d \"%s\"",
@@ -372,6 +389,9 @@
cp->cli->sb = vsb_newauto();
XXXAN(cp->cli->sb);
+ if (params->cli_banner)
+ (void)VLU_Data("banner\n", -1, cp->vlu);
+
cp->ev = calloc(sizeof *cp->ev, 1);
cp->ev->name = cp->name;
cp->ev->fd = fdi;
Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2009-02-13 09:49:11 UTC (rev 3761)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2009-02-13 10:13:27 UTC (rev 3762)
@@ -757,6 +757,11 @@
"Detect and eliminate duplicate purges.\n",
0,
"off", "bool" },
+ { "cli_banner", tweak_bool, &master.cli_banner, 0, 0,
+ "Emit CLI banner on connect.\n"
+ "Set to off for compatibility with pre 2.1 versions.\n",
+ 0,
+ "on", "bool" },
{ NULL, NULL, NULL }
};
Modified: trunk/varnish-cache/include/cli.h
===================================================================
--- trunk/varnish-cache/include/cli.h 2009-02-13 09:49:11 UTC (rev 3761)
+++ trunk/varnish-cache/include/cli.h 2009-02-13 10:13:27 UTC (rev 3762)
@@ -225,6 +225,12 @@
"\tCheck status of Varnish cache process.", \
0, 0
+#define CLI_BANNER \
+ "banner", \
+ "banner", \
+ "\tPrint welcome banner.", \
+ 0, 0
+
#define CLI_HIDDEN(foo, min_arg, max_arg) \
foo, NULL, NULL, min_arg, max_arg,
More information about the varnish-commit
mailing list